How to download image files in internal (App's private) storage react native
I am working on a react-native project in which I need to download some image files from the server and save them inside the App. These must be saved in the internal private storage of the App such that the app user must not be able to find these files (in non-rooted phone). I have searched on google and found the below options:
- Use AsyncStorage and save the image files in the Base64 string format. (I want to avoid this because this will add overhead [increase file size little bit] + unnecessary task of converting to/from base64)
- Use rn-fetch-blob library to directly fetch from/to the server in blob format but I unable to find the internal storage saving options. This options helps me to store files on Documents or Download etc but I need to store files in the internal memory.
- I can use URI as a source for all the images but I want to avoid dependency on the server as much as I can.
Please suggest a simple way to download image[ or other format] file in the react native app which must be inside App's private data folder without any conversion into string or any other medium.
javascript
add a comment |
I am working on a react-native project in which I need to download some image files from the server and save them inside the App. These must be saved in the internal private storage of the App such that the app user must not be able to find these files (in non-rooted phone). I have searched on google and found the below options:
- Use AsyncStorage and save the image files in the Base64 string format. (I want to avoid this because this will add overhead [increase file size little bit] + unnecessary task of converting to/from base64)
- Use rn-fetch-blob library to directly fetch from/to the server in blob format but I unable to find the internal storage saving options. This options helps me to store files on Documents or Download etc but I need to store files in the internal memory.
- I can use URI as a source for all the images but I want to avoid dependency on the server as much as I can.
Please suggest a simple way to download image[ or other format] file in the react native app which must be inside App's private data folder without any conversion into string or any other medium.
javascript
add a comment |
I am working on a react-native project in which I need to download some image files from the server and save them inside the App. These must be saved in the internal private storage of the App such that the app user must not be able to find these files (in non-rooted phone). I have searched on google and found the below options:
- Use AsyncStorage and save the image files in the Base64 string format. (I want to avoid this because this will add overhead [increase file size little bit] + unnecessary task of converting to/from base64)
- Use rn-fetch-blob library to directly fetch from/to the server in blob format but I unable to find the internal storage saving options. This options helps me to store files on Documents or Download etc but I need to store files in the internal memory.
- I can use URI as a source for all the images but I want to avoid dependency on the server as much as I can.
Please suggest a simple way to download image[ or other format] file in the react native app which must be inside App's private data folder without any conversion into string or any other medium.
javascript
I am working on a react-native project in which I need to download some image files from the server and save them inside the App. These must be saved in the internal private storage of the App such that the app user must not be able to find these files (in non-rooted phone). I have searched on google and found the below options:
- Use AsyncStorage and save the image files in the Base64 string format. (I want to avoid this because this will add overhead [increase file size little bit] + unnecessary task of converting to/from base64)
- Use rn-fetch-blob library to directly fetch from/to the server in blob format but I unable to find the internal storage saving options. This options helps me to store files on Documents or Download etc but I need to store files in the internal memory.
- I can use URI as a source for all the images but I want to avoid dependency on the server as much as I can.
Please suggest a simple way to download image[ or other format] file in the react native app which must be inside App's private data folder without any conversion into string or any other medium.
javascript
javascript
asked Nov 26 '18 at 10:51
Shubham1164Shubham1164
6817
6817
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can use Document Directory as path to save your files. It keeps the files inside the storage of application which you want and when you want to retrieve the files, then you already knows the base path and you just need to supply the filename to access the file.
const dirs = RNFetchBlob.fs.dirs;
RNFetchBlob
.config({
path : dirs.DocumentDir + `${folder_name}/${filename}`
}).fetch('GET', `${fileURL}`).progress((received=0, total=0) => {
//Handle progress of download here.. May be update UI...
}).then((resp) => {
//You can get the path of the file saved using resp.path()
.catch((err) => {
//Handle error here...
});
Hope this helps. Happy coding :)
Can the app user see my files here?
– Shubham1164
Nov 26 '18 at 11:20
No apparently. In iOS a strict NO, and in android, it can be viewed by hacking the way via the android/data/appid/data/obb and all..... if you are getting what i am trying to specify. But thats all that the other apps does. If you need some kind of encryption then you have to manually encrypt and decrypt the file before saving and after fetching.
– Suraj Malviya
Nov 26 '18 at 11:32
1
Yes. Thanks Suraj.
– Shubham1164
Nov 26 '18 at 11:34
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53479538%2fhow-to-download-image-files-in-internal-apps-private-storage-react-native%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use Document Directory as path to save your files. It keeps the files inside the storage of application which you want and when you want to retrieve the files, then you already knows the base path and you just need to supply the filename to access the file.
const dirs = RNFetchBlob.fs.dirs;
RNFetchBlob
.config({
path : dirs.DocumentDir + `${folder_name}/${filename}`
}).fetch('GET', `${fileURL}`).progress((received=0, total=0) => {
//Handle progress of download here.. May be update UI...
}).then((resp) => {
//You can get the path of the file saved using resp.path()
.catch((err) => {
//Handle error here...
});
Hope this helps. Happy coding :)
Can the app user see my files here?
– Shubham1164
Nov 26 '18 at 11:20
No apparently. In iOS a strict NO, and in android, it can be viewed by hacking the way via the android/data/appid/data/obb and all..... if you are getting what i am trying to specify. But thats all that the other apps does. If you need some kind of encryption then you have to manually encrypt and decrypt the file before saving and after fetching.
– Suraj Malviya
Nov 26 '18 at 11:32
1
Yes. Thanks Suraj.
– Shubham1164
Nov 26 '18 at 11:34
add a comment |
You can use Document Directory as path to save your files. It keeps the files inside the storage of application which you want and when you want to retrieve the files, then you already knows the base path and you just need to supply the filename to access the file.
const dirs = RNFetchBlob.fs.dirs;
RNFetchBlob
.config({
path : dirs.DocumentDir + `${folder_name}/${filename}`
}).fetch('GET', `${fileURL}`).progress((received=0, total=0) => {
//Handle progress of download here.. May be update UI...
}).then((resp) => {
//You can get the path of the file saved using resp.path()
.catch((err) => {
//Handle error here...
});
Hope this helps. Happy coding :)
Can the app user see my files here?
– Shubham1164
Nov 26 '18 at 11:20
No apparently. In iOS a strict NO, and in android, it can be viewed by hacking the way via the android/data/appid/data/obb and all..... if you are getting what i am trying to specify. But thats all that the other apps does. If you need some kind of encryption then you have to manually encrypt and decrypt the file before saving and after fetching.
– Suraj Malviya
Nov 26 '18 at 11:32
1
Yes. Thanks Suraj.
– Shubham1164
Nov 26 '18 at 11:34
add a comment |
You can use Document Directory as path to save your files. It keeps the files inside the storage of application which you want and when you want to retrieve the files, then you already knows the base path and you just need to supply the filename to access the file.
const dirs = RNFetchBlob.fs.dirs;
RNFetchBlob
.config({
path : dirs.DocumentDir + `${folder_name}/${filename}`
}).fetch('GET', `${fileURL}`).progress((received=0, total=0) => {
//Handle progress of download here.. May be update UI...
}).then((resp) => {
//You can get the path of the file saved using resp.path()
.catch((err) => {
//Handle error here...
});
Hope this helps. Happy coding :)
You can use Document Directory as path to save your files. It keeps the files inside the storage of application which you want and when you want to retrieve the files, then you already knows the base path and you just need to supply the filename to access the file.
const dirs = RNFetchBlob.fs.dirs;
RNFetchBlob
.config({
path : dirs.DocumentDir + `${folder_name}/${filename}`
}).fetch('GET', `${fileURL}`).progress((received=0, total=0) => {
//Handle progress of download here.. May be update UI...
}).then((resp) => {
//You can get the path of the file saved using resp.path()
.catch((err) => {
//Handle error here...
});
Hope this helps. Happy coding :)
answered Nov 26 '18 at 11:08
Suraj MalviyaSuraj Malviya
855414
855414
Can the app user see my files here?
– Shubham1164
Nov 26 '18 at 11:20
No apparently. In iOS a strict NO, and in android, it can be viewed by hacking the way via the android/data/appid/data/obb and all..... if you are getting what i am trying to specify. But thats all that the other apps does. If you need some kind of encryption then you have to manually encrypt and decrypt the file before saving and after fetching.
– Suraj Malviya
Nov 26 '18 at 11:32
1
Yes. Thanks Suraj.
– Shubham1164
Nov 26 '18 at 11:34
add a comment |
Can the app user see my files here?
– Shubham1164
Nov 26 '18 at 11:20
No apparently. In iOS a strict NO, and in android, it can be viewed by hacking the way via the android/data/appid/data/obb and all..... if you are getting what i am trying to specify. But thats all that the other apps does. If you need some kind of encryption then you have to manually encrypt and decrypt the file before saving and after fetching.
– Suraj Malviya
Nov 26 '18 at 11:32
1
Yes. Thanks Suraj.
– Shubham1164
Nov 26 '18 at 11:34
Can the app user see my files here?
– Shubham1164
Nov 26 '18 at 11:20
Can the app user see my files here?
– Shubham1164
Nov 26 '18 at 11:20
No apparently. In iOS a strict NO, and in android, it can be viewed by hacking the way via the android/data/appid/data/obb and all..... if you are getting what i am trying to specify. But thats all that the other apps does. If you need some kind of encryption then you have to manually encrypt and decrypt the file before saving and after fetching.
– Suraj Malviya
Nov 26 '18 at 11:32
No apparently. In iOS a strict NO, and in android, it can be viewed by hacking the way via the android/data/appid/data/obb and all..... if you are getting what i am trying to specify. But thats all that the other apps does. If you need some kind of encryption then you have to manually encrypt and decrypt the file before saving and after fetching.
– Suraj Malviya
Nov 26 '18 at 11:32
1
1
Yes. Thanks Suraj.
– Shubham1164
Nov 26 '18 at 11:34
Yes. Thanks Suraj.
– Shubham1164
Nov 26 '18 at 11:34
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53479538%2fhow-to-download-image-files-in-internal-apps-private-storage-react-native%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown