Files
Uploading and managing files.
Sample code on this page is based on the initial assumptions.
Managing Files
Uploading a File
To place a file in the Store, you need to create a file handle using the createFile(...)
function. The function accepts a StoreId
,
public and private metadata,the total size of the file that will be uploaded, and set up a flag that tells whether the file has the random write feature enabled.
Then you need to call writeToFile(...)
providing the created file handle and a portion of data to write. For small files, you can write the entire file with one request. For large files, it's more optimal to write them piece by piece, loading them in portions, for example from the disk, and then calling writeToFile(...)
on each piece.
To complete the entire file upload process - call closeFile(...)
with the file handle as a parameter.
Creating a File
Creating a File with Random Write Support
Listing Files
To retrieve the contents of the Store, you can call the listFiles(...)
function to get a list of files from the specified Store.
As a result you will receive an object:
A detailed description of the File
object fields can be found in API Reference.
Reading a File
To read a file, you can do it with a single request or - which is usually a better solution for large files - by reading it piece by piece.
You must start by opening the file for reading using the openFile(fileId)
function. As a result, you'll receive a file handle that
you then use when calling readFromFile(...)
to read portions of data from the file. At the same time, you have the ability to move through
the file and indicate from which position you want to read it using the seekInFile(...)
function.
Modifying Files
File modification can be considered in two categories:
- Modifying file information.
- Modifying data in the file.
To update information about a file, you need to use the updateFileMeta(...)
.
Updating a File
To update the data of the particular file you have to use updateFile(...)
method.
This method can also be used to modify metadata (just like updateFileMeta(...)
), but additionally it creates a file handle allowing for writing data to the file.
Updating a File with Random Write Support
To update the data of the particular file, that has random write flag enabled, you have to use the openFile(...)
method.
The openFile(...)
method is used when you want to modify a fragment of file data.
It requires the file to have random write support and creates a read/write handle, allowing you to write new data to any position in the file.
When using the read/write handle, data is always sent to the server after each writeToFile(...)
call.
Deleting a File
To delete a file, you need to use the deleteFile(...)
method.
We use cookies on our website. We use them to ensure the proper functioning of the site and, if you agree, for purposes we set, such as analytics or marketing.