Files
Working with large data.
The sample code on this page is based on the initial assumptions.
publicMeta and privateMeta fields in Files support any kind of data formats encoded to byte arrays.
Examples in this section use JSON format serialization, which is available directly in Swift.\
FilePrivateMeta structure used in the code below is defined as such:
Uploading Files
The most basic way of uploading a File to a Store:
Retrieving Files
Downloading information about Files
To retrieve information about a singular File call getFile(_:) method:
Downloading a File
You can simply call the startDownloadingToFile(_:from:) method on the PrivMXEndpoint instance.
This utilizes the PrivMXStoreFileHandler under the hood.
Seeking in a File
Once you acquire a handle to the File by calling openFile(_:), you can move the handle to point at any byte of the file by calling seekInFile(withHandle:toPosition:):
Managing Files
Updating a File
There are two ways to update a File. You can either only update its metadata, or you can reupload a new version of the File. The latter can be done in three ways similar to uploading a new file.
To only update the File's metadata call updateFileMeta(of:replacingPublicMeta:replacingPrivateMeta:):
Deleting Files
To delete a File call deleteFile(_:) method.
Working with Random Write Files
Working with a Random Write File starts from acquiring a handle.
Once you have a handle you can read the File you can Read from it...
... move the handle to any byte of the File...
... or overwrite parts of the File.
The size of a File with Random Write functionality adjusts dynamically.
Once you finish working with the File you should close it.
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.