Files external object

Official Content
This documentation is valid for:

The Files external object enables you to programmatically select files from your device to be assigned to Blob and BlobFile attributes and variables.

image_20222762327_1_png Untitled_20222762612_1_png

Properties

It does not have any.

Methods

ChooseFile method

Selects a file from the device.

Return value  BlobFile
Parameters [ acceptedTypes:VarChar data type ]

 

The method will display the available sources in the device to select a file. In the case of iOS applications, these sources will be:

  • Local file (files in the application's sandbox)
  • Files application (introduced from iOS 11)
  • Image gallery

IOSFileSources

The optional acceptedTypes parameter must be specified as a comma-separated list of mime types, such as:

  • "image/*" to indicate that only images files can be selected,
  • "application/pdf" for PDF files, or
  • "image/*,application/pdf" to allow selecting images and PDF files.

Note: the acceptedTypes parameter is available in Android since GeneXus 16 upgrade 10. It is not yet available in iOS.

If the acceptedTypes parameter is not present, then all file types are shown.

 

SaveToFolder method

Saves the specified File to the device system folder.

Return Value Boolean

Parameters  fileUri:URL, destination:DeviceFolder, /* saveMode: SaveMode */.

The parameter saveMode is optional. The default behavior is Rename.

Events

It does not have any

Domains

DeviceFolder

Values: Documents, Dowloads.

SaveMode

Values: 

Rename: If a file already exists in destination, creates a copy.
Replace: If a file already exists in destination, will replace the content if possible. If not possible for secure reason, do a Renamed
AskUser: If file already exists in destination, will ask the user if to do a Replacement or Rename.

Considerations

If the file already exists in the destination folder, by default it is renamed so that both files are kept. Override with the new name is composed by the original name, an index between parentheses, and the file extension.
For example, when saving Name.ext, if it already exists, it will be saved as Name(1).ext. If Name(1).ext also exists, Name(2).ext will be used. And so on.

If SaveMode is Replace, If the file already exists in the destination folder, it is overriding with the new content if possible. If not, a Renamed is performing.

 

Example

Event 'SelectFile'
  Composite
    &BlobFile = Files.ChooseFile()
    SaveFile(&BlobFile)
  EndComposite
EndEvent

Event 'SaveToFolder'

&fileUrl = Reporte("MyPublicReport")
Files.SaveToFolder( &fileUrl, DeviceFolder.Documents)

EndEvent

Scope

Platforms  Smart Devices