PrivMXStoreFileHandler
A class providing a set of tools using SwiftNIO for uploading and downloading files with the use of PrivMXStore
from PrivMX Endpoint.
Fields
RecommendedChunkSize
Int64
Recommended chunk size for file transfers, suggested by the endpoint library.
mode
StoreFileHandlerMode
hasDataLeft
Bool
Static Methods
getStoreFileUpdater(for:withReplacement:using:replacingPublicMeta:replacingPrivateMeta:replacingFileSize:chunkSize:)
Creates a handler for updating a file with a new data buffer.
Params
fileId
String
The ID of the file to be updated.
sourceFile
FileHandle
The FileHandle (swift-nio) with new file content.
storesApi
any PrivMXStore
The API for interacting with the PrivMXStore
.
publicMeta
Data
The new public metadata for the file.
privateMeta
Data
The new private metadata for the file.
fileSize
Int64
The size of the file to be updated.
chunkSize
Int64
The size of the chunks for the upload. Defaults to the recommended chunk size.
Returns
PrivMXStoreFileHandler
·
A new PrivMXStoreFileHandler
instance configured for updating the file.
getStoreFileCreator(inStore:from:using:withPublicMeta:withPrivateMeta:fileSize:chunkSize:)
Creates a handler for creating a new file from a data buffer.
Params
storeId
String
The ID of the store where the file will be created.
sourceFile
FileHandle
The FileHandle (swift-nio) with new file content.
storesApi
any PrivMXStore
The API for interacting with the PrivMXStore
.
publicMeta
Data
The public metadata for the new file.
privateMeta
Data
The private metadata for the new file.
fileSize
Int64
The size of the new file.
chunkSize
Int64
The size of the chunks for the upload. Defaults to the recommended chunk size.
Returns
PrivMXStoreFileHandler
·
A new PrivMXStoreFileHandler
instance configured for creating the file.
getStoreFileUpdater(for:withReplacementBuffer:using:replacingPublicMeta:replacingPrivateMeta:replacingFileSize:chunkSize:)
Creates a handler for updating a file with a new data buffer.
Params
fileId
String
The ID of the file to be updated.
sourceBuffer
Data
The data buffer to replace the existing file content.
storesApi
any PrivMXStore
The API for interacting with the PrivMXStore
.
publicMeta
Data
The new public metadata for the file.
privateMeta
Data
The new private metadata for the file.
fileSize
Int64
The size of the file to be updated.
chunkSize
Int64
The size of the chunks for the upload. Defaults to the recommended chunk size.
Returns
PrivMXStoreFileHandler
·
A new PrivMXStoreFileHandler
instance configured for updating the file.
getStoreFileCreator(inStore:fromBuffer:using:withPublicMeta:withPrivateMeta:fileSize:chunkSize:)
Creates a handler for updating a file with a new data buffer.
Params
storeId
String
The ID of the Store in which the file is to be created.
sourceBuffer
Data
The data buffer to replace the existing file content.
storesApi
any PrivMXStore
The API for interacting with the PrivMXStore
.
publicMeta
Data
The new public metadata for the file.
privateMeta
Data
The new private metadata for the file.
fileSize
Int64
The size of the file to be updated.
chunkSize
Int64
The size of the chunks for the upload. Defaults to the recommended chunk size.
Returns
PrivMXStoreFileHandler
·
A new PrivMXStoreFileHandler
instance configured for updating the file.
getStoreFileReader(saveTo:readFrom:with:chunkSize:)
Creates a new handler for downloading a file and saving it to a local file.
Params
outputFile
FileHandle
The local file handle (swift-nio) where the downloaded file content will be saved.
fileId
String
The ID of the file to be downloaded from the PrivMXStore
.
storesApi
any PrivMXStore
The API for interacting with the PrivMXStore
.
chunkSize
Int64
The size of the chunks for downloading. Defaults to the recommended chunk size.
Returns
PrivMXStoreFileHandler
·
A new PrivMXStoreFileHandler
instance configured for downloading the file to the local file.
getStoreFileReader(readFrom:with:chunkSize:)
Creates a new handler for downloading a file to an internal buffer.
This method allows downloading a file from the PrivMXStore
directly into memory (a buffer). To retrieve the buffer after the download, call getBuffer()
.
Params
fileId
String
The ID of the file to be downloaded from the PrivMXStore
.
storesApi
any PrivMXStore
The API for interacting with the PrivMXStore
.
chunkSize
Int64
The size of the chunks for downloading. Defaults to the recommended chunk size.
Returns
PrivMXStoreFileHandler
·
A new PrivMXStoreFileHandler
instance configured for downloading the file into the buffer.
Methods
getBuffer()
Provides access to the data buffer of the processed file.
Returns
Data?
·
The processed data buffer.
close()
Closes both local and remote files.
Returns
String
·
A string representing the result of closing the remote file.
readChunk(onChunkDownloaded:)
Downloads the next chunk and adds it to either the local file or the internal buffer, depending on the mode.
Params
onChunkDownloaded
(@escaping @Sendable (Int) -> Void)
A closure called when a chunk is downloaded, passing the byte count of the chunk.
writeChunk(onChunkUploaded:)
Uploads the next chunk of data from the local file or buffer to the remote file.
Params
onChunkUploaded
(@escaping @Sendable (Int) -> Void)
A closure called when a chunk is uploaded, passing the byte count of the chunk.
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.
PrivMX Endpoint Swift v2.3