Networking

Base network task

  • Base class for network task wrappers.

    After a network request is made via DBTransportClient, a subclass of DBTask is returned, from which response and progress handlers can be installed, and the network response paused or cancelled.

    Handlers are executed on the thread specified by the DBDelegate instance with which the DBTask instance is initialied (more specifically, the delegate queue that the DBDelegate uses to execute handler code). By default, this is the main thread, which makes updating UI elements in response handlers convenient.

    While response handlers are not optional, they do not necessarily need to have been installed by the time the SDK has received its server response. If this is the case, completion data will be saved, and the handler will be executed with the completion data upon its installation. Downloaded content will be moved from a temporary location to the final destination when the response handler code is executed.

    See more

    Declaration

    Objective-C

    @interface DBTask : NSObject {
      NSOperationQueue *_queue;
    }

    Swift

    class DBTask : NSObject

RPC-style network task

  • Dropbox RPC-style Network Task.

    After an RPC network request is made via DBTransportClient, a subclass of DBRpcTask is returned, from which response and progress handlers can be installed, and the network response paused or cancelled.

    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.

    See more

    Declaration

    Objective-C

    @interface DBRpcTask<TResponse, TError> : DBTask

    Swift

    class DBRpcTask<TResponse, TError> : DBTask where TResponse : AnyObject, TError : AnyObject

Upload-style network task

  • Dropbox Upload-style Network Task.

    After an Upload network request is made via DBTransportClient, a subclass of DBUploadTask is returned, from which response and progress handlers can be installed, and the network response paused or cancelled.

    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.

    See more

    Declaration

    Objective-C

    @interface DBUploadTask<TResponse, TError> : DBTask

    Swift

    class DBUploadTask<TResponse, TError> : DBTask where TResponse : AnyObject, TError : AnyObject

Download-style network task (NSURL)

  • 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.

    See more

    Declaration

    Objective-C

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

    Swift

    class DBDownloadUrlTask<TResponse, TError> : DBTask where TResponse : AnyObject, TError : AnyObject

Download-style network task (NSData)

  • 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.

    See more

    Declaration

    Objective-C

    @interface DBDownloadDataTask<TResponse, TError> : DBTask

    Swift

    class DBDownloadDataTask<TResponse, TError> : DBTask where TResponse : AnyObject, TError : AnyObject

DBRequestError generic error

  • Base class for generic network request error (as opposed to route-specific error).

    This class is represented almost like a Stone “Union” object. As one object, it can represent a number of error “states” (see all of the values of DBRequestErrorType). To handle each error type, call each of the is<TAG_STATE> methods until you determine the current tag state, then call the corresponding as<TAG_STATE> method to return an instance of the appropriate error type.

    For example:

    if ([dbxError isHTTPError]) { DBHttpError *httpError = [dbxError asHttpError]; } else if ([dbxError isBadInputError]) { ……..

    See more

    Declaration

    Objective-C

    @interface DBRequestError : NSObject

    Swift

    class DBRequestError : NSObject

HTTP error

  • Http request error.

    Contains relevant information regarding a failed network request. All error types except for DBClientError extend this class as children. Initialized in the event of a generic, unidentified HTTP error.

    See more

    Declaration

    Objective-C

    @interface DBRequestHttpError : NSObject

    Swift

    class DBRequestHttpError : NSObject

Bad Input error

  • Bad Input request error.

    Contains relevant information regarding a failed network request. Initialized in the event of an HTTP 400 response. Extends DBRequestHttpError.

    See more

    Declaration

    Objective-C

    @interface DBRequestBadInputError : DBRequestHttpError

    Swift

    class DBRequestBadInputError : DBRequestHttpError

Auth error

  • Auth request error.

    Contains relevant information regarding a failed network request. Initialized in the event of an HTTP 401 response. Extends DBRequestHttpError.

    See more

    Declaration

    Objective-C

    @interface DBRequestAuthError : DBRequestHttpError

    Swift

    class DBRequestAuthError : DBRequestHttpError

Access error

  • Access request error.

    Contains relevant information regarding a failed network request. Initialized in the event of an HTTP 403 response. Extends DBRequestHttpError.

    See more

    Declaration

    Objective-C

    @interface DBRequestAccessError : DBRequestHttpError

    Swift

    class DBRequestAccessError : DBRequestHttpError

Rate limit error

  • Rate limit request error.

    Contains relevant information regarding a failed network request. Initialized in the event of an HTTP 429 response. Extends DBRequestHttpError.

    See more

    Declaration

    Objective-C

    @interface DBRequestRateLimitError : DBRequestHttpError

    Swift

    class DBRequestRateLimitError : DBRequestHttpError

Internal Server error

  • Internal Server request error.

    Contains relevant information regarding a failed network request. Initialized in the event of an HTTP 500 response. Extends DBRequestHttpError.

    See more

    Declaration

    Objective-C

    @interface DBRequestInternalServerError : DBRequestHttpError

    Swift

    class DBRequestInternalServerError : DBRequestHttpError

Client error

  • Client side request error.

    Contains relevant information regarding a failed network request. Initialized in the event of a client-side error, like an invalid url host, or making a request when not connected to the internet.

    See more

    Declaration

    Objective-C

    @interface DBRequestClientError : NSObject

    Swift

    class DBRequestClientError : NSObject
  • Configuration class for DBTransportBaseClient.

    See more

    Declaration

    Objective-C

    @interface DBTransportBaseConfig : NSObject

    Swift

    class DBTransportBaseConfig : NSObject
  • Configuration class for DBTransportDefaultClient.

    See more

    Declaration

    Objective-C

    @interface DBTransportDefaultConfig : DBTransportBaseConfig

    Swift

    class DBTransportDefaultConfig : DBTransportBaseConfig
  • Allows for consistent, global handling of route-specific error types, as well as general network errors.

    Normally, error handling is done on a request-by-request basis, in the supplied response handler. However, it is convenient to handle some error behavior consistently, regardless of the request or the endpoint. An example of this might be implementing retry logic for all rate-limiting errors, regardless of their source. For implementing global error handling for general networking errors like rate-limiting, one of the registerNetworkErrorResponseBlock: methods should be used. For implementing global error handling for route-specific errors, one of the registerRouteErrorResponseBlock: methods should be used.

    For the route-specific error handling, you may supply either the direct route error type, or any type that the route error type contains as an instance field (or an instance field of an instance field, and so on).

    Note

    These globally supplied response handlers will be executed in place of the original request-specific response handler. At most one global response handler will be executed, with the prioirty going to the general network response handler, followed by the handler that is associated directly with the route’s error response type, followed by the handler associated with the first matching instance field.
    See more

    Declaration

    Objective-C

    @interface DBGlobalErrorResponseHandler : NSObject

    Swift

    class DBGlobalErrorResponseHandler : NSObject
  • The networking client for the User and Business API.

    Normally, one networking client should instantiated per access token and session / background session pair. By default, all Upload-style and Download-style requests are made via a background session (except when uploading via NSInputStream or NSData, or downloading to NSData, in which case, it is not possible) and all RPC-style request are made using a foreground session.

    Requests are made via one of the request methods below. The request is launched, and a DBTask object is returned, from which response and progress handlers can be added directly. By default, these handlers are added / executed using the main thread queue and executed in a thread-safe manner (unless a custom delegate queue is supplied via the DBTransportDefaultConfig object). An internal DBDelegate object then retrieves the appropriate handler and executes it.

    While response handlers are not optional, they do not necessarily need to have been installed by the time the SDK has received its server response. If this is the case, completion data will be saved, and the handler will be executed with the completion data upon its installation. Downloaded content will be moved from a temporary location to the final destination when the response handler code is executed.

    Argument serialization and deserialization is performed with this class.

    See more

    Declaration

    Objective-C

    @interface DBTransportDefaultClient : DBTransportBaseClient <DBTransportClient>

    Swift

    class DBTransportDefaultClient : DBTransportBaseClient, DBTransportClient
  • 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.

    Declaration

    Objective-C

    typedef void (^DBProgressBlock)(int64_t, int64_t, int64_t)

    Swift

    typealias DBProgressBlock = (Int64, Int64, Int64) -> Void
  • Special custom response block for batch upload. The first argument is a mapping of client-side NSURLs to batch upload result entries (each of which indicates the success / failure of the upload for the corresponding file). This object will be nonnull if the final call to /upload_session/finish_batch/check is successful. The second argument is the route-specific error from /upload_session/finish_batch/check, which is generally not able to be handled at runtime, but instead should be used for debugging purposes. This object will be nonnull if there is a route-specific error from the call to /upload_session/finish_batch/check. The third argument is the general request error from /upload_session/finish_batch/check. This object will be nonnull if there is a request error from the call to /upload_session/finish_batch/check. The fourth argument is a mapping of client-side NSURLs to general request errors, which occured during the upload of the corresponding file.

    Declaration

    Objective-C

    typedef void (^DBBatchUploadResponseBlock)(
        NSDictionary<NSURL *, DBFILESUploadSessionFinishBatchResultEntry *>
            *_Nullable,
        DBASYNCPollError *_Nullable, DBRequestError *_Nullable,
        NSDictionary<NSURL *, DBRequestError *> *_Nonnull)

    Swift

    typealias DBBatchUploadResponseBlock = ([URL : DBFILESUploadSessionFinishBatchResultEntry]?, DBASYNCPollError?, DBRequestError?, [URL : DBRequestError]) -> Void
  • Task storage for upload and download tasks.

    Offers a convenient, thread-safe storage option for upload and download tasks so that they can be cancelled later.

    See more

    Declaration

    Objective-C

    @interface DBTasksStorage : NSObject

    Swift

    class DBTasksStorage : NSObject