Skip to main content
Version: 12.x (Current)

File Manager

<bk-file-manager></bk-file-manager>

Manages file upload transactions by holding a unique transaction ID hash map. Since files are often linked to a collection entry but stored on a different service, it might be handy to control file upload through a transaction manager. Two steps are needed to successfully upload a file:

  1. handle file uploads to a storage service. Assuming a backend service such as Mia Platform's Files Service, a component like the File Service Client could perform such task.
  2. handle updates to the CRUD collection. Assuming a backend service such as Mia Platform's CRUD Service, this task could be handled by the CRUD Client.

The File Manager component processes requests originating from other components to create or update data in a CRUD collection, which also require operations involving uploading files to a designated file storage service. The requests that trigger these actions are typically in the form of create-data-with-file or update-data-with-file events.

These events encapsulate both the data to be created or updated and additional information within their meta section. The meta data aids in extracting the files that require uploading from the payload.

The flow of this process can be summarized as follows:

  • The File Manager identifies within the payload all files that should be uploaded.
  • For each identified file, the File Manager initiates an upload request to the designated file storage service.
  • Upon receiving notifications confirming successful file uploads, the File Manager proceeds to signal the request for creating or updating data using the complete payload from the initial triggering event.
  • However, in the event of an error notification being received, the entire transaction is retracted. This includes deleting any files that were already uploaded as part of the incomplete transaction.

Further details on how Back-Kit components can be composed to handle file fields are available in the specific section.

How to configure

The File Manger does not require any configuration.

{
"tag": "bk-file-manager"
}

API

Properties & Attributes

None

Listens to

eventactionemitson error
update-data-with-fileinitiates an upload file transaction attaching a unique ID and attempting upload file to the storage serviceupload-file-
create-data-with-fileinitiates an upload file transaction attaching a unique ID and attempting upload file to the storage serviceupload-file-
uploaded-filecontinues a create-data-with-file or update-data-with-file transaction by patching the CRUD collection with the upload-file metadataupdate-data,create-data-
errorinterrupts a registered transaction due to an occurred error event carrying a meta. If the file was stored but the collection wasn't successfully patched, then the file is deleteddelete-file-

Emits

eventdescription
upload-filecontains file and metadata to be stored
update-dataafter storage, contains reference metadata used to patch a collection containing reference to such file
create-dataafter storage, contains reference metadata used to create an item into collection containing reference to such file
create-dataafter storage, contains reference metadata used to create an item into collection containing reference to such file
delete-filecontains file metadata to trigger file deletion