The purpose of the BlobFile data type is to store or reference any kind of files (image, audio, video, pdf, excel, etc.), regardless of their format. The data can be stored locally or by using any external storage media.
The properties and methods are similar to those available for Image data type, Audio data type and Video data type.
||Gets the file name (Character).
||Gets the file Type.
Sets/Gets the FileURI
You can set a relative path. It will be resolved within the current host.
You can set a local path by using file:// protocol
When you set the URI property, the internal binary file stored in the DB will be set to empty.
&Blobfile.FileURI = "http://www.myfiles/file.pdf"
In this case, the .pdf file will be the file in the data.
It always returns the absolute URI to the file
Loads the current instance with the file given in the parameter FileURL.
The internal binary holding the file is loaded from the FileURL indicated.
After calling this method, the URI property has the filename and the extension of the FileURL specified.
msg(&Blobfile.FileURI) // will print myfile.pdf
The File can be loaded from a URI (local or remote) using FromURL method. If the value passed to FromURL is a remote URL, the file is downloaded (and saved to the DB if it's necessary).
If what you want is simply to have a reference to the file that is somewhere remote or local, you just need to assign the URI property.
The BlobFile data type is automatically stored as more than one field in the DB (similar to the way Image data type, Audio data type and Video data type are stored).
The structure saved in the DB is the following:
- Attribute_Name (Binary is stored here)
- GXI_Attribute_Name (where the URI is stored) (GXI = GeneXus Identifier)
When the URI is assigned, GXI_Attribute_Name is assumed to be an external file (in this case the full URI is stored). If the file was loaded using FromURL method, the relative path is saved there (so the file name and type are known).
When a file is stored, the file name is stored in the GXI field, as follows:
gxdbfile: <file name> _ <token>. <file extension>
The prefix "gxdbfile:" indicates to GeneXus that it is a file and not a relative URL.
The token allows to identify univocally the file. GeneXus generates a GUID.
The difference between Blob and BlobFile data type is the way they are stored in the database. As a result, BlobFile can be stored in any external storage whereas Blob data type cannot.
The following reorganizations are supported:
- From Blob to BlobFile -> The binary file is copied, and the GXI_Attribute_Name is obtained through the name of the original blob file.
- From Character to BlobFile -> The GXI_Attribute_Name is set from the character attribute
- From BlobFile to Blob -> The GXI_Attribute_Name field is removed
- From BlobFile to Character -> The field is assigned, if possible, using the GXI_Attribute_Name value. Otherwise, it's left empty.