@@ -113,7 +113,7 @@ - (NSMutableDictionary *)getMetadataForUrl:(NSURL *)url error:(NSError **)error
113
113
if (mode == UIDocumentPickerModeOpen) {
114
114
[urlsInOpenMode addObject: url];
115
115
}
116
-
116
+
117
117
// TODO handle error
118
118
[url startAccessingSecurityScopedResource ];
119
119
@@ -124,12 +124,12 @@ - (NSMutableDictionary *)getMetadataForUrl:(NSURL *)url error:(NSError **)error
124
124
[coordinator coordinateReadingItemAtURL: url options: NSFileCoordinatorReadingResolvesSymbolicLink error: &fileError byAccessor: ^(NSURL *newURL) {
125
125
// If the coordinated operation fails, then the accessor block never runs
126
126
result[FIELD_URI] = ((mode == UIDocumentPickerModeOpen) ? url : newURL).absoluteString ;
127
-
127
+
128
128
NSError *copyError;
129
- NSString *maybeFileCopyPath = copyDestination ? [RNDocumentPicker copyToUniqueDestinationFrom: newURL usingDestinationPreset: copyDestination error: copyError]. absoluteString : nil ;
130
-
129
+ NSURL *maybeFileCopyPath = copyDestination ? [RNDocumentPicker copyToUniqueDestinationFrom: newURL usingDestinationPreset: copyDestination error: & copyError] : nil ;
130
+
131
131
if (!copyError) {
132
- result[FIELD_FILE_COPY_URI] = RCTNullIfNil (maybeFileCopyPath);
132
+ result[FIELD_FILE_COPY_URI] = RCTNullIfNil (maybeFileCopyPath. absoluteString );
133
133
} else {
134
134
result[FIELD_COPY_ERR] = copyError.localizedDescription ;
135
135
result[FIELD_FILE_COPY_URI] = [NSNull null ];
@@ -191,21 +191,21 @@ - (NSMutableDictionary *)getMetadataForUrl:(NSURL *)url error:(NSError **)error
191
191
resolve (nil );
192
192
}
193
193
194
- + (NSURL *)copyToUniqueDestinationFrom : (NSURL *)url usingDestinationPreset : (NSString *)copyToDirectory error : (NSError *)error
194
+ + (NSURL *)copyToUniqueDestinationFrom : (NSURL *)url usingDestinationPreset : (NSString *)copyToDirectory error : (NSError ** )error
195
195
{
196
196
NSURL *destinationRootDir = [self getDirectoryForFileCopy: copyToDirectory];
197
197
// we don't want to rename the file so we put it into a unique location
198
198
NSString *uniqueSubDirName = [[NSUUID UUID ] UUIDString ];
199
199
NSURL *destinationDir = [destinationRootDir URLByAppendingPathComponent: [NSString stringWithFormat: @" %@ /" , uniqueSubDirName]];
200
200
NSURL *destinationUrl = [destinationDir URLByAppendingPathComponent: [NSString stringWithFormat: @" %@ " , url.lastPathComponent]];
201
201
202
- [NSFileManager .defaultManager createDirectoryAtURL: destinationDir withIntermediateDirectories: YES attributes: nil error: & error];
203
- if (error) {
204
- return url ;
202
+ [NSFileManager .defaultManager createDirectoryAtURL: destinationDir withIntermediateDirectories: YES attributes: nil error: error];
203
+ if (* error) {
204
+ return nil ;
205
205
}
206
- [NSFileManager .defaultManager copyItemAtURL: url toURL: destinationUrl error: & error];
207
- if (error) {
208
- return url ;
206
+ [NSFileManager .defaultManager copyItemAtURL: url toURL: destinationUrl error: error];
207
+ if (* error) {
208
+ return nil ;
209
209
} else {
210
210
return destinationUrl;
211
211
}
0 commit comments