SBBUploadManager Class Reference

Inherits from SBBBridgeAPIManager : NSObject
Conforms to SBBComponent
SBBUploadManagerProtocol
Declared in SBBUploadManager.h
SBBUploadManager.m

Overview

This class handles communication with the Bridge file upload API.

– uploadFileToBridge:completion:

This is a convenience method that determines the appropriate content-type based on the file extension and calls through to uploadFileToBridge:contentType:completion:.

- (void)uploadFileToBridge:(NSURL *)fileUrl completion:(SBBUploadManagerCompletionBlock)completion

Declared In

SBBUploadManager.h

– uploadFileToBridge:contentType:completion:

Upload a file to the Bridge server on behalf of the authenticated user, via the NSURLSessionUploadTask so it can proceed even if the app is suspended or killed. Requesting the pre-signed URL for the upload from the Bridge API happens in a background download task so that the whole process can be initiated regardless of current network connectivity, and will proceed as and when possible.

- (void)uploadFileToBridge:(NSURL *)fileUrl contentType:(NSString *)contentType completion:(SBBUploadManagerCompletionBlock)completion

Parameters

fileUrl

The file to upload.

contentType

The MIME type of the file (defaults to “application/octet-stream” if nil).

completion

A completion block to be called when the upload finishes (or fails). Note that this will never be called if the app has to be relaunched to respond to the background session delegate events; blocks cannot be persisted across app launches. If you need to be sure to get the call upon completion (successful or otherwise), set an uploadDelegate.

Discussion

The file is copied to a temporary file with a unique name in the temporary directory, and the copy is uploaded, so the original can be safely deleted any time after making this call (though you may want to wait and do it in the uploadManager:uploadOfFile:completedWithError: method, in case the upload fails so you can try again). The temporary copy is deleted upon successful or unsuccessful completion of the upload attempt.

Declared In

SBBUploadManager.h