UploadTask
public final class UploadTask<Method> : Cancellable where Method : PCloudAPIMethod
extension UploadTask: CustomStringConvertible
Executes an upload to the pCloud API.
-
Undocumented
Declaration
Swift
public typealias Parser = Method.Parser
-
Undocumented
Declaration
Swift
public typealias CompletionBlock = (Result<Method.Value, CallError<Method.Error>>) -> Void
-
true
ifcancel()
has been invoked on this instance,false
otherwise.Declaration
Swift
public var isCancelled: Bool { get }
-
Initializes a non-running task with a network operation and a parser.
Declaration
Swift
public init(operation: UploadOperation, responseParser: @escaping Parser)
Parameters
operation
An operation in a suspended state that would execute the upload.
responseParser
A block parsing an object from a response dictionary.
-
Adds a completion block to this instance to be called when the task completes either successfully or with a failure.
Declaration
Swift
@discardableResult public func addCompletionBlock(_ block: @escaping CompletionBlock) -> UploadTask
Parameters
block
A block called on the main thread with the result of the task.
Return Value
This task.
-
Adds a progress block to this instance to be called continuously as data is being uploaded.
Declaration
Swift
@discardableResult public func addProgressBlock(_ block: @escaping (Int64, Int64) -> Void) -> UploadTask
Parameters
block
A block called on the main thread with the number of uploaded bytes and the total number of bytes to upload as first and second arguments, respectively. Called each time the number of uploaded bytes changes.
Return Value
This task.
-
Starts the task if it is not already running.
Declaration
Swift
@discardableResult public func start() -> UploadTask
Return Value
This task.
-
Interrupts and invalidates the task. An invalidated task cannot run again.
Declaration
Swift
public func cancel()
-
Declaration
Swift
public var description: String { get }