DBDownloadUrlTask

@interface DBDownloadUrlTask <TResponse, TError> : DBTask{
  NSURL *_destination;
  BOOL _overwrite;
}

Dropbox Download-style Network Task (download to NSURL).

After an Upload network request is made via DBTransportClient, a subclass of DBDownloadUrlTask 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 NSURL 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. In the event the request returns successfully, but a handler is not yet installed, the downloaded content will be moved to a temporary location (NSTemporaryDirectory()) until the response handler is installed, at which point the file content will be moved to its final destination.

    Declaration

    Objective-C

    - (nonnull DBDownloadUrlTask<TResponse, TError> *)setResponseBlock:
        (nonnull DBDownloadUrlResponseBlock)responseBlock;

    Swift

    func setResponseBlock(_ responseBlock: @escaping (TResponse?, TError?, DBRequestError?, URL) -> Void) -> DBDownloadUrlTask<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 destination to which the file was downloaded.

    Return Value

    The current DBDownloadUrlTask 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 DBDownloadUrlTask<TResponse, TError> *)
    setResponseBlock:(nonnull DBDownloadUrlResponseBlock)responseBlock
               queue:(nullable NSOperationQueue *)queue;

    Swift

    func setResponseBlock(_ responseBlock: @escaping (TResponse?, TError?, DBRequestError?, URL) -> Void, queue: OperationQueue?) -> DBDownloadUrlTask<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 destination to which the file was downloaded.

    queue

    The operation queue on which to execute the response.

    Return Value

    The current DBDownloadUrlTask 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 DBDownloadUrlTask *)setProgressBlock:
        (nonnull DBProgressBlock)progressBlock;

    Swift

    func setProgressBlock(_ progressBlock: @escaping DBProgressBlock) -> DBDownloadUrlTask<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 DBDownloadUrlTask 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 DBDownloadUrlTask *)
    setProgressBlock:(nonnull DBProgressBlock)progressBlock
               queue:(nullable NSOperationQueue *)queue;

    Swift

    func setProgressBlock(_ progressBlock: @escaping DBProgressBlock, queue: OperationQueue?) -> DBDownloadUrlTask<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 DBDownloadUrlTask instance.