BlobFile data type

Official Content
This documentation is valid for:

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.

Properties and Methods

The properties and methods are similar to those available for Image data type, Audio data type and Video data type.

Properties

FileName Gets the file name (Character).
FileType Gets the file Type. 
FileURI

Sets/Gets the FileURI

Set:
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.

Example:

&Blobfile.FromURL(myFileWillbeErasedInNextLine)
&Blobfile.FileURI = "http://www.myfiles/file.pdf"

In this case, the .pdf file will be the file in the data.

Get:

It always returns the absolute URI to the file

Methods

FromURL(FileURL)

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.

For example:
 

&Blobfile.FromURL('www.myfiles.com/myfile.pdf')
msg(&Blobfile.FileURI) // will print myfile.pdf

 

SetEmpty/IsEmpty  

How does it work?

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.

How is it stored in the DB?

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.

What is the difference beetwen Blob data type and BlobFile data type?

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.

Reorganizations

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.

Availability

Since GeneXus 15 upgrade 12. It isn't available for SD apps yet (Android).

 




Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.