|
24 | 24 | #import "PFMacros.h"
|
25 | 25 | #import "PFRESTFileCommand.h"
|
26 | 26 | #import "PFErrorUtilities.h"
|
| 27 | +#import "Parse.h" |
| 28 | +#import "PFFileUploadController.h" |
27 | 29 |
|
28 | 30 | static NSString *const PFFileControllerCacheDirectoryName_ = @"PFFileCache";
|
29 | 31 |
|
@@ -218,21 +220,41 @@ - (NSString *)_temporaryFileDownloadPathForFileState:(PFFileState *)fileState {
|
218 | 220 | return [BFTask taskWithError:error];
|
219 | 221 | }
|
220 | 222 |
|
221 |
| - PFRESTFileCommand *command = [PFRESTFileCommand uploadCommandForFileWithName:fileState.name sessionToken:sessionToken]; |
222 |
| - @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<PFCommandResult *> *task) { |
229 |
| - @strongify(self); |
230 |
| - PFCommandResult *result = task.result; |
231 |
| - PFFileState *fileState = [[PFFileState alloc] initWithName:result.result[@"name"] |
232 |
| - urlString:result.result[@"url"] |
233 |
| - mimeType:nil]; |
234 |
| - return [[self _cacheFileAsyncWithState:fileState atPath:sourceFilePath] continueWithSuccessResult:fileState]; |
235 |
| - }]; |
| 223 | + |
| 224 | + id<PFFileUploadController> customFileUploadController = Parse.currentConfiguration.fileUploadController; |
| 225 | + if (customFileUploadController) { |
| 226 | + @weakify(self); |
| 227 | + return [[customFileUploadController uploadSourceFilePath:sourceFilePath |
| 228 | + fileName:fileState.name |
| 229 | + mimeType:fileState.mimeType |
| 230 | + sessionToken:sessionToken |
| 231 | + cancellationToken:cancellationToken |
| 232 | + progressBlock:progressBlock] |
| 233 | + continueWithSuccessBlock:^id(BFTask<PFFileUploadResult *> *task) { |
| 234 | + @strongify(self); |
| 235 | + PFFileUploadResult *result = task.result; |
| 236 | + PFFileState *fileState = [[PFFileState alloc] initWithName:result.name |
| 237 | + urlString:result.url |
| 238 | + mimeType:nil]; |
| 239 | + return [[self _cacheFileAsyncWithState:fileState atPath:sourceFilePath] continueWithSuccessResult:fileState]; |
| 240 | + }]; |
| 241 | + } else { |
| 242 | + PFRESTFileCommand *command = [PFRESTFileCommand uploadCommandForFileWithName:fileState.name sessionToken:sessionToken]; |
| 243 | + @weakify(self); |
| 244 | + return [[self.dataSource.commandRunner runFileUploadCommandAsync:command |
| 245 | + withContentType:fileState.mimeType |
| 246 | + contentSourceFilePath:sourceFilePath |
| 247 | + options:PFCommandRunningOptionRetryIfFailed |
| 248 | + cancellationToken:cancellationToken |
| 249 | + progressBlock:progressBlock] continueWithSuccessBlock:^id(BFTask<PFCommandResult *> *task) { |
| 250 | + @strongify(self); |
| 251 | + PFCommandResult *result = task.result; |
| 252 | + PFFileState *fileState = [[PFFileState alloc] initWithName:result.result[@"name"] |
| 253 | + urlString:result.result[@"url"] |
| 254 | + mimeType:nil]; |
| 255 | + return [[self _cacheFileAsyncWithState:fileState atPath:sourceFilePath] continueWithSuccessResult:fileState]; |
| 256 | + }]; |
| 257 | + } |
236 | 258 | }
|
237 | 259 |
|
238 | 260 | ///--------------------------------------
|
|
0 commit comments