|
23 | 23 | #import "PFHash.h"
|
24 | 24 | #import "PFMacros.h"
|
25 | 25 | #import "PFRESTFileCommand.h"
|
| 26 | +#import "PFErrorUtilities.h" |
26 | 27 |
|
27 | 28 | static NSString *const PFFileControllerCacheDirectoryName_ = @"PFFileCache";
|
28 | 29 |
|
@@ -90,6 +91,11 @@ - (BFTask *)downloadFileAsyncWithState:(PFFileState *)fileState
|
90 | 91 | if (cancellationToken.cancellationRequested) {
|
91 | 92 | return [BFTask cancelledTask];
|
92 | 93 | }
|
| 94 | + if (!fileState.secureURLString) { |
| 95 | + NSError *error = [PFErrorUtilities errorWithCode:kPFErrorUnsavedFile |
| 96 | + message:@"Can't download a file that doesn't exist on the server or locally."]; |
| 97 | + return [BFTask taskWithError:error]; |
| 98 | + } |
93 | 99 |
|
94 | 100 | @weakify(self);
|
95 | 101 | return [BFTask taskFromExecutor:[BFExecutor defaultPriorityBackgroundExecutor] withBlock:^id{
|
@@ -208,13 +214,17 @@ - (BFTask *)uploadFileAsyncWithState:(PFFileState *)fileState
|
208 | 214 | sessionToken:(NSString *)sessionToken
|
209 | 215 | cancellationToken:(BFCancellationToken *)cancellationToken
|
210 | 216 | progressBlock:(PFProgressBlock)progressBlock {
|
211 |
| - PFRESTFileCommand *command = [PFRESTFileCommand uploadCommandForFileWithName:fileState.name |
212 |
| - sessionToken:sessionToken]; |
213 |
| - |
214 |
| - @weakify(self); |
215 | 217 | if (cancellationToken.cancellationRequested) {
|
216 | 218 | return [BFTask cancelledTask];
|
217 | 219 | }
|
| 220 | + if (!sourceFilePath) { |
| 221 | + NSError *error = [PFErrorUtilities errorWithCode:kPFErrorUnsavedFile |
| 222 | + message:@"Can't upload a file that doesn't exist locally."]; |
| 223 | + return [BFTask taskWithError:error]; |
| 224 | + } |
| 225 | + |
| 226 | + PFRESTFileCommand *command = [PFRESTFileCommand uploadCommandForFileWithName:fileState.name sessionToken:sessionToken]; |
| 227 | + @weakify(self); |
218 | 228 | return [[[self.dataSource.commandRunner runFileUploadCommandAsync:command
|
219 | 229 | withContentType:fileState.mimeType
|
220 | 230 | contentSourceFilePath:sourceFilePath
|
|
0 commit comments