DBDownloadDataTask

@interface DBDownloadDataTask <TResponse, TError> : DBTask

Dropbox Download Network Task (download to NSData).

After an Upload network request is made via DBTransportClient, a subclass of DBDownloadDataTask is returned, from which response and progress handlers can be installed, and the network response paused or cancelled. Note, this class is returned only for download requests with an NSData output.

TResponse is the generic representation of the route-specific result, and TError is the generic representation of the route-specific error.

Response / error deserialization is performed with this class.

  • Installs a response handler for the current request.

    Executes handler on main queue/thread.

    Note

    Any existing handlers are replaced by the supplied handler.

    Declaration

    Objective-C

    - (nonnull DBDownloadDataTask<TResponse, TError> *)setResponseBlock:
        (nonnull DBDownloadDataResponseBlock)responseBlock;

    Swift

    func setResponseBlock(_ responseBlock: @escaping (TResponse?, TError?, DBRequestError?, Data?) -> Void) -> DBDownloadDataTask<TResponse, TError>

    Parameters

    responseBlock

    The handler block to be executed in the event of a successful or unsuccessful network request. The first argument is the route-specific result. The second argument is the route-specific error. And the third argument is the more general network error (which includes information like Dropbox request ID, http status code, etc.). The fourth argument is the output NSData object in memory, to which the file was downloaded.

    Return Value

    The current DBDownloadDataTask instance.

  • Installs a response handler for the current request with a specific queue on which to execute handler code.

    Executes handler on supplied queue/thread.

    Note

    Any existing handlers are replaced by the supplied handler.

    Declaration

    Objective-C

    - (nonnull DBDownloadDataTask<TResponse, TError> *)
    setResponseBlock:(nonnull DBDownloadDataResponseBlock)responseBlock
               queue:(nullable NSOperationQueue *)queue;

    Swift

    func setResponseBlock(_ responseBlock: @escaping (TResponse?, TError?, DBRequestError?, Data?) -> Void, queue: OperationQueue?) -> DBDownloadDataTask<TResponse, TError>

    Parameters

    responseBlock

    The handler block to be executed in the event of a successful or unsuccessful network request. The first argument is the route-specific result. The second argument is the route-specific error. And the third argument is the more general network error (which includes information like Dropbox request ID, http status code, etc.). The fourth argument is the output NSData object in memory, to which the file was downloaded.

    queue

    The operation queue on which to execute the response.

    Return Value

    The current DBDownloadDataTask instance.

  • Installs a progress handler for the current request.

    Executes handler on main queue/thread.

    Note

    Any existing handlers are replaced by the supplied handler.

    Declaration

    Objective-C

    - (nonnull DBDownloadDataTask *)setProgressBlock:
        (nonnull DBProgressBlock)progressBlock;

    Swift

    func setProgressBlock(_ progressBlock: @escaping DBProgressBlock) -> DBDownloadDataTask<AnyObject, AnyObject>

    Parameters

    progressBlock

    The progress block to be executed in the event of a request update. The first argument is the number of bytes downloaded. The second argument is the number of total bytes downloaded. And the third argument is the number of total bytes expected to be downloaded.

    Return Value

    The current DBDownloadDataTask instance.

  • Installs a progress handler for the current request.

    Executes handler on supplied queue/thread.

    Note

    Any existing handlers are replaced by the supplied handler.

    Declaration

    Objective-C

    - (nonnull DBDownloadDataTask *)
    setProgressBlock:(nonnull DBProgressBlock)progressBlock
               queue:(nullable NSOperationQueue *)queue;

    Swift

    func setProgressBlock(_ progressBlock: @escaping DBProgressBlock, queue: OperationQueue?) -> DBDownloadDataTask<AnyObject, AnyObject>

    Parameters

    progressBlock

    The progress block to be executed in the event of a request update. The first argument is the number of bytes downloaded. The second argument is the number of total bytes downloaded. And the third argument is the number of total bytes expected to be downloaded.

    queue

    The operation queue on which to execute the response.

    Return Value

    The current DBDownloadDataTask instance.