InboxFileHandler
A class providing a set of tools using SwiftNIO for uploading and downloading files with the use of PrivMXInbox
from PrivMX Endpoint.
Fields
RecommendedChunkSize
Int64
Recommended chunk size for file transfers, suggested by the endpoint library.
fileHandle
Int64
InboxFileHandle
mode
InboxFileHandlerMode
The mode of this handler
hasDataLeft
Bool
Static Methods
getInboxFileReaderToBuffer(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
.
inboxApi
any PrivMXInbox
chunkSize
Int64
The size of the chunks for downloading. Defaults to the recommended chunk size.
Returns
InboxFileHandler
·
A new PrivMXStoreFileHandler
instance configured for downloading the file into the buffer.
getInboxFileReaderToFile(readFrom:with:to:chunkSize:)
Creates a new handler for downloading a file to a local File.
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
.
inboxApi
any PrivMXInbox
localFile
FileHandle
SwiftNIO handle to a file on the device
chunkSize
Int64
The size of the chunks for downloading. Defaults to the recommended chunk size.
Returns
InboxFileHandler
·
A new PrivMXStoreFileHandler
instance configured for downloading the File into the local file.
Methods
setEntryHandle(_:)
Sets the Entry handle for uploading the file.
Params
handle
privmx.EntryHandle
Entry handle received by preparing an Inbox Entry
setInboxHandle(_:)
Params
handle
privmx.InboxHandle
getBuffer()
Provides access to the data buffer of the processed file.
Returns
Data?
·
The processed data buffer.
closeSource()
Closes local FileDataSource
.
closeRemote()
Closes remote File.
Returns
String
·
Id of 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