PrivMX DOCS
API Reference/PrivMX Endpoint Swift Extra/Inboxes

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.

public static func getInboxFileReaderToBuffer(
readFrom fileId:String,
with inboxApi:any PrivMXInbox,
chunkSize: Int64 = InboxFileHandler.RecommendedChunkSize
) throws -> InboxFileHandler

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.

public static func getInboxFileReaderToFile(
readFrom fileId:String,
with inboxApi:any PrivMXInbox,
to localFile:FileHandle,
chunkSize: Int64 = InboxFileHandler.RecommendedChunkSize
) throws -> InboxFileHandler

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

public func setEntryHandle(
_ handle: privmx.EntryHandle
) -> Void

setInboxHandle(_:)

Params

handle

privmx.InboxHandle

public func setInboxHandle(
_ handle: privmx.InboxHandle
) -> Void

getBuffer()

Provides access to the data buffer of the processed file.

public func getBuffer(
) -> Data?

Returns

Data? · The processed data buffer.

closeSource()

Closes local FileDataSource.

public func closeSource(
) throws -> Void

closeRemote()

Closes remote File.

public func closeRemote(
) throws -> String

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.

public func readChunk(
onChunkDownloaded: (@escaping @Sendable (Int)->Void) = {byteCount in}
) throws -> Void

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.

public func writeChunk(
onChunkUploaded: (@escaping @Sendable (Int) -> Void) = {byteCount in}
) throws -> Void

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

This package is not up to date with the core documentation. Some of the features you've seen described in other parts of the documentation might not be mentioned here. Those changes do not influence compatibility, however