@@ -139,17 +139,17 @@ - (BFTask *)downloadFileStreamAsyncWithState:(PFFileState *)fileState
139139 NSString *filePath = [self _temporaryFileDownloadPathForFileState: fileState];
140140 PFFileDataStream *stream = [[PFFileDataStream alloc ] initWithFileAtPath: filePath];
141141 [[self downloadFileAsyncWithState: fileState
142- cancellationToken: cancellationToken
143- progressBlock: ^(int percentDone) {
144- [taskCompletionSource trySetResult: stream];
145-
146- if (progressBlock) {
147- progressBlock (percentDone);
148- }
149- }] continueWithBlock: ^id (BFTask *task) {
150- [stream stopBlocking ];
151- return task;
152- }];
142+ cancellationToken: cancellationToken
143+ progressBlock: ^(int percentDone) {
144+ [taskCompletionSource trySetResult: stream];
145+
146+ if (progressBlock) {
147+ progressBlock (percentDone);
148+ }
149+ }] continueWithBlock: ^id (BFTask *task) {
150+ [stream stopBlocking ];
151+ return task;
152+ }];
153153 return taskCompletionSource.task ;
154154 }];
155155}
@@ -204,11 +204,11 @@ - (NSString *)_temporaryFileDownloadPathForFileState:(PFFileState *)fileState {
204204#pragma mark - Upload
205205// /--------------------------------------
206206
207- - (BFTask *)uploadFileAsyncWithState : (PFFileState *)fileState
208- sourceFilePath : (NSString *)sourceFilePath
209- sessionToken : (NSString *)sessionToken
210- cancellationToken : (BFCancellationToken *)cancellationToken
211- progressBlock : (PFProgressBlock)progressBlock {
207+ - (BFTask<PFFileState *> *)uploadFileAsyncWithState : (PFFileState *)fileState
208+ sourceFilePath : (NSString *)sourceFilePath
209+ sessionToken : (NSString *)sessionToken
210+ cancellationToken : (BFCancellationToken *)cancellationToken
211+ progressBlock : (PFProgressBlock)progressBlock {
212212 if (cancellationToken.cancellationRequested ) {
213213 return [BFTask cancelledTask ];
214214 }
@@ -220,20 +220,18 @@ - (BFTask *)uploadFileAsyncWithState:(PFFileState *)fileState
220220
221221 PFRESTFileCommand *command = [PFRESTFileCommand uploadCommandForFileWithName: fileState.name sessionToken: sessionToken];
222222 @weakify (self);
223- return [[[self .dataSource.commandRunner runFileUploadCommandAsync: command
224- withContentType: fileState.mimeType
225- contentSourceFilePath: sourceFilePath
226- options: PFCommandRunningOptionRetryIfFailed
227- cancellationToken: cancellationToken
228- progressBlock: progressBlock] continueWithSuccessBlock: ^id (BFTask *task) {
223+ return [[self .dataSource.commandRunner runFileUploadCommandAsync: command
224+ withContentType: fileState.mimeType
225+ contentSourceFilePath: sourceFilePath
226+ options: PFCommandRunningOptionRetryIfFailed
227+ cancellationToken: cancellationToken
228+ progressBlock: progressBlock] continueWithSuccessBlock: ^id (BFTask<PFCommandResult *> *task) {
229+ @strongify (self);
229230 PFCommandResult *result = task.result ;
230231 PFFileState *fileState = [[PFFileState alloc ] initWithName: result.result[@" name" ]
231232 urlString: result.result[@" url" ]
232233 mimeType: nil ];
233- return fileState;
234- }] continueWithSuccessBlock: ^id (BFTask<PFFileState *> *task) {
235- @strongify (self);
236- return [self _cacheFileAsyncWithState: task.result atPath: sourceFilePath];
234+ return [[self _cacheFileAsyncWithState: fileState atPath: sourceFilePath] continueWithSuccessResult: fileState];
237235 }];
238236}
239237
0 commit comments