itinance / itinance/react-native-fs

JPG Image is not getting downloaded

Open
#1,080 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
5k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

```
export default async (url, callback) => {
console.log(url);
const ext = url.indexOf(".jpg") !== -1 ? ".jpg" : ".mp4";
// console.log(isImage);
let date = new Date();
let fileName = date.toDateString() + date.getMilliseconds() + date.getTime();
RNFS.downloadFile({
fromUrl: url,
toFile:
(ext === ".mp4" ? RNFS.MovieDirectoryPath : RNFS.DownloadDirectoryPath) +
"/My/" +
fileName +
ext,
background: true,
headers: {
"Cache-Control": "no-store",
},
})
.promise.then(() => {
callback(
`${ext === ".jpg" ? "Photo" : "Video"} Successfully saved to gallery.`
);
})
.catch((err) => {
if (
err ===
"[Error: Download manager failed to download from Status Code = 16]"
) {
return;
}
console.log(err);
callback(null, err);
});
};
```
Getting Below Error:
`[Error: ENOENT: no such file or directory, open '/storage/emulated/0/Download/My/Tue Mar 01 20222011646150422201.jpg']`

Video are getting downloaded properly problem is with jpg files.

`PS: I have made changes to native module so that I can access 'MovieDirectory' Folder`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.