JBStrap Filestore API

For file handling, the framework comes with an API called FileStoreAPI . This API allows the simple execution of file operations, such as saving to, deleting or reading from the FileStore (s). Every file operation’s default parameter is its own unique ID, which is called the FileID. This is determined when the files are stored. The storing and use of this ID must be implemented in the application logic.

Saving files

You can store JBFile objects to the File Store. The JBFile represents a file. The files containing the JBFile objects are saved during storage, to the specified FileStore . Thus, the API also manages the physical storing of the files.

Storing a file to a specified FileStore:
Storing a file, and reading the recieved FileStore for the file’s ID:

Getting files

You can get a previously stored file if you know its ID and the name of the FileStore . You will receive a JBFile object which contains the requested file and its metadata.

Getting a file from the ‘myFileStore’ FileStore. The file name will be example.txt:

Deleting files

You can also delete a file, if you know its ID and the name of the FileStore where it is stored.

Deleting a file from the ‘myFileStore’ FileStore:

Saving files with a Record save

Certain files are handled automatically, if the files are in a Record, and the Record was saved through a properly parameterized DataDescriptor , and you use this to save it to the database. In this case, the files are not saved to the database, but in the appropriate FileStore . The only things that will be saved to the Database are the file’s metadata, so it can be later determined, which file(s) belong to which records. In a Record, the files must be in a list, that is made of JBFile objects, in order for the saving process to be fully operational. Likewise, if a Record is read from the database, through a properly parameterized DataDescriptor , and there are files belonging to the Record, the files will be in a JBFile list. The list will be in the Record. For more details, such as how this works, how to parameterize and how to customize this process, please refer to the File storage page

Related pages