itinance / itinance/react-native-fs
Suggestion: Add file length check before sending
- Dominant language
- C++
- Stars
- 5k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
``` obj-c
NSData *fileData = [NSData dataWithContentsOfFile:filepath];
if ([fileData length] == 0) {
NSError *error = [NSError errorWithDomain:@"" code:77 userInfo:[NSDictionary dictionaryWithObject:@"empty" forKey:NSLocalizedDescriptionKey]];
_params.errorCallback(error);
return;
}
```
Would be a nice enhancement. Sometimes when getting files from the ios document picker `didPickDocumentAtURL:(NSURL *)`
the URL is (randomly) linked to an empty file and checking with the FileManager can often not be enough that we would catch
``` js
.catch((err) => {
callback();
if(err.description === "empty") {
//display empty error message
}
if(err.description === "cancelled") {
// cancelled by user
} else {
this.logUnexpectedError(err);
}
console.log(err);
});
```
Sources:
http://stackoverflow.com/questions/8809054/fileexistsatpath-returns-no-for-a-directory-that-exists?rq=1
https://stackoverflow.com/questions/37109130/uidocumentpickerviewcontroller-returns-url-to-a-file-that-does-not-exist
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.