Skip to content

Commit 9a94cab

Browse files
authored
Merge pull request #48 from cristianoccazinsp/ios-handle-write-failure
check write results to handle failures
2 parents a9af868 + e87e4af commit 9a94cab

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

ios/ReactNativeBlobUtilFS.m

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,10 @@ + (void) writeFile:(NSString *)path
396396
[fileHandle closeFile];
397397
}
398398
else {
399-
[content writeToFile:path atomically:YES];
399+
if (![content writeToFile:path atomically:YES]) {
400+
fm = nil;
401+
return reject(@"EUNSPECIFIED", [NSString stringWithFormat:@"File '%@' could not be written.", path], nil);
402+
}
400403
}
401404
fm = nil;
402405

@@ -460,7 +463,11 @@ + (void) writeFileArray:(NSString *)path
460463
[fileHandle closeFile];
461464
}
462465
else {
463-
[fileContent writeToFile:path atomically:YES];
466+
if (![fileContent writeToFile:path atomically:YES]) {
467+
free(bytes);
468+
fm = nil;
469+
return reject(@"EUNSPECIFIED", [NSString stringWithFormat:@"File '%@' could not be written.", path], nil);
470+
}
464471
}
465472
}
466473
free(bytes);

0 commit comments

Comments
 (0)