@@ -124,10 +124,10 @@ - (NSMutableDictionary *)getMetadataForUrl:(NSURL *)url error:(NSError **)error
124
124
result[FIELD_URI] = ((mode == UIDocumentPickerModeOpen) ? url : newURL).absoluteString ;
125
125
126
126
NSError *copyError;
127
- NSString *maybeFileCopyPath = copyDestination ? [RNDocumentPicker copyToUniqueDestinationFrom: newURL usingDestinationPreset: copyDestination error: copyError]. absoluteString : nil ;
127
+ NSURL *maybeFileCopyPath = copyDestination ? [RNDocumentPicker copyToUniqueDestinationFrom: newURL usingDestinationPreset: copyDestination error: & copyError] : nil ;
128
128
129
129
if (!copyError) {
130
- result[FIELD_FILE_COPY_URI] = RCTNullIfNil (maybeFileCopyPath);
130
+ result[FIELD_FILE_COPY_URI] = RCTNullIfNil (maybeFileCopyPath. absoluteString );
131
131
} else {
132
132
result[FIELD_COPY_ERR] = copyError.localizedDescription ;
133
133
result[FIELD_FILE_COPY_URI] = [NSNull null ];
@@ -193,21 +193,21 @@ - (void)pickDirectory:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBl
193
193
reject (@" RNDocumentPicker:pickDirectory" , @" pickDirectory is not supported on iOS" , nil );
194
194
}
195
195
196
- + (NSURL *)copyToUniqueDestinationFrom : (NSURL *)url usingDestinationPreset : (NSString *)copyToDirectory error : (NSError *)error
196
+ + (NSURL *)copyToUniqueDestinationFrom : (NSURL *)url usingDestinationPreset : (NSString *)copyToDirectory error : (NSError ** )error
197
197
{
198
198
NSURL *destinationRootDir = [self getDirectoryForFileCopy: copyToDirectory];
199
199
// we don't want to rename the file so we put it into a unique location
200
200
NSString *uniqueSubDirName = [[NSUUID UUID ] UUIDString ];
201
201
NSURL *destinationDir = [destinationRootDir URLByAppendingPathComponent: [NSString stringWithFormat: @" %@ /" , uniqueSubDirName]];
202
202
NSURL *destinationUrl = [destinationDir URLByAppendingPathComponent: [NSString stringWithFormat: @" %@ " , url.lastPathComponent]];
203
203
204
- [NSFileManager .defaultManager createDirectoryAtURL: destinationDir withIntermediateDirectories: YES attributes: nil error: & error];
205
- if (error) {
206
- return url ;
204
+ [NSFileManager .defaultManager createDirectoryAtURL: destinationDir withIntermediateDirectories: YES attributes: nil error: error];
205
+ if (* error) {
206
+ return nil ;
207
207
}
208
- [NSFileManager .defaultManager copyItemAtURL: url toURL: destinationUrl error: & error];
209
- if (error) {
210
- return url ;
208
+ [NSFileManager .defaultManager copyItemAtURL: url toURL: destinationUrl error: error];
209
+ if (* error) {
210
+ return nil ;
211
211
} else {
212
212
return destinationUrl;
213
213
}
0 commit comments