Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DropBlocks/Classes/DropBlocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ typedef void (^LoadThumbnailCallback)(DBMetadata *metadata, NSError *error);
typedef void (^UploadFileCallback)(NSString*, DBMetadata *metadata, NSError *error);
typedef void (^UploadFileProgressCallback)(CGFloat progress);
typedef void (^UploadFileChunkCallback)(NSString *uploadId, unsigned long long offset, NSDate *expiresDate, NSError *error);
typedef void (^UploadFileChunkProgressCallback)(CGFloat progress);
typedef void (^LoadRevisionsCallback)(NSArray *revisions, NSError *error);
typedef void (^RestoreFileCallback)(DBMetadata *metadata, NSError *error);
typedef void (^CreateFolderCallback)(DBMetadata *metadata, NSError *error);
Expand Down Expand Up @@ -48,7 +49,7 @@ typedef void (^LoadSharableLinkCallback)(NSString *link, NSError *error);

+ (void)uploadFile:(NSString *)filename toPath:(NSString *)path withParentRev:(NSString *)parentRev fromPath:(NSString *)sourcePath completionBlock:(UploadFileCallback)completionBlock progressBlock:(UploadFileProgressCallback)progressBlock;

+ (void)uploadFileChunk:(NSString *)uploadId offset:(unsigned long long)offset fromPath:(NSString *)localPath completionBlock:(UploadFileChunkCallback)completionBlock;
+ (void)uploadFileChunk:(NSString *)uploadId offset:(unsigned long long)offset fromPath:(NSString *)localPath completionBlock:(UploadFileChunkCallback)completionBlock progressBlock:(UploadFileChunkProgressCallback)progressBlock;

+ (void)uploadFile:(NSString *)filename toPath:(NSString *)parentFolder withParentRev:(NSString *)parentRev fromUploadId:(NSString *)uploadId completionBlock:(UploadFileCallback)completionBlock;

Expand Down
18 changes: 16 additions & 2 deletions DropBlocks/Classes/DropBlocks.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ + (void)uploadFile:(NSString *)filename toPath:(NSString *)path withParentRev:(N
//- (void)uploadFile:(NSString*)filename toPath:(NSString*)path fromPath:(NSString *)sourcePath __attribute__((deprecated));


+ (void)uploadFileChunk:(NSString *)uploadId offset:(unsigned long long)offset fromPath:(NSString *)localPath completionBlock:(UploadFileChunkCallback)completionBlock {
[[DropBlocks newInstanceWithCallback:completionBlock].restClient uploadFileChunk:uploadId offset:offset fromPath:localPath];
+ (void)uploadFileChunk:(NSString *)uploadId offset:(unsigned long long)offset fromPath:(NSString *)localPath completionBlock:(UploadFileChunkCallback)completionBlock progressBlock:(UploadFileChunkProgressCallback)progressBlock {
DropBlocks* db = [DropBlocks newInstanceWithCallback:completionBlock];
db.secondaryCallback = progressBlock;
[db.restClient uploadFileChunk:uploadId offset:offset fromPath:localPath];
}

+ (void)uploadFile:(NSString *)filename toPath:(NSString *)parentFolder withParentRev:(NSString *)parentRev fromUploadId:(NSString *)uploadId completionBlock:(UploadFileCallback)completionBlock {
Expand Down Expand Up @@ -321,6 +323,18 @@ - (void)restClient:(DBRestClient *)client uploadFileChunkFailedWithError:(NSErro
[strongSelf cleanup];
}

- (void)restClient:(DBRestClient *)client uploadFileChunkProgress:(CGFloat)progress
forFile:(NSString *)uploadId offset:(unsigned long long)offset fromPath:(NSString *)localPath {
//we can run into dealloc problems unless we keep a strong reference to ourselves till the method is done
DropBlocks* strongSelf = self;
UploadFileProgressCallback handler = strongSelf.secondaryCallback;

if (handler) {
handler(progress);
}

}

- (void)restClient:(DBRestClient *)client uploadedFile:(NSString *)destPath fromUploadId:(NSString *)uploadId
metadata:(DBMetadata *)metadata {
//we can run into dealloc problems unless we keep a strong reference to ourselves till the method is done
Expand Down