Skip to main content

Managing Files

Stores allow you to exchange and save files. In this section, we'll take a closer look at file structures and how to manage them effectively. We'll also cover some best practices when working with Stores.

About Files

Along with a file's main content, additional metadata is stored to allow easy file management. Below is the structure of the metadata associated with each file:

fieldtypeencrypteddescription
infoServerFileInfoyesadditional information assigned by the server e.g. author, creationDate, storeID and fileID
publicMetabinarynoadditional public information about the message, also accessible through Bridge API
privateMetabinaryyesadditional information about the message
sizenumberyesThe size of file in getBytes
authorPubKeystringyesThe public key of the author of the file
statusCodenumberno0 if the file was decrypted successfully

Listing Files

Info

The sample code on this page is based on the same assumptions mentioned in Managing Stores.

Here's how you can retrieve and list files from a Store:

    core::PagingQuery query = {.skip = 0, .limit = 30, .sortOrder = "desc"};

// list files of the Store specified by storeId
auto filesResult {storesApi.listFiles(storeId, query)};
for (auto file: filesResult.readItems) {
std::cout << "File ID: " << file.info.fileId << std::endl;
std::cout << "File size: " << file.size << std::endl;
}

Deleting Files

Deleting a file is straightforward, but be aware that this action is irreversible:

	// deleting file specified by fileId
storesApi.deleteFile(fileId);