Issue
I am working on a react native project. I need to store the captured images in the custom folder.
I am using react native fs library for that. I am able to create the image in the desired directory but I am not able to see those images in my iphones' file directory.
Here is my code I am using to store the images.
async moveAttachment(capturedImagePath) {
$filePathDir = `${RNFS.DocumentDirectoryPath}/myapp/myfilename`;
$filePath = `${$filePathDir }/myfilename.png`;
return new Promise((resolve, reject) => {
RNFS.mkdir(filePathDir)
.then(() => {
RNFS.moveFile(capturedImagePath, filePath )
.then(() => resolve(dirPictures))
.catch(error => reject(error));
})
.catch(err => reject(err));
});
}
I am able to see the image in my simulator's document directory but not able to see in the iPhone > files directory.
Please help me to figure this out.
Solution
You should be able to enable it by updating your Info.plist
. You need to add two keys:
UIFileSharingEnabled
and LSSupportsOpeningDocumentsInPlace
should both be added and set to YES
.
UIFileSharingEnabled
: Application supports iTunes file sharingLSSupportsOpeningDocumentsInPlace
: Supports opening documents in place
This will allow your DocumentsDirectory
to be opened in iTunes and it should also allow you to share your files via the Files
application.
You can read more about LSSupportsOpeningDocumentsInPlace
here
In iOS 11 and later, if both this key and the
UIFileSharingEnabled
key areYES
, the local file provider grants access to all the documents in the app’sDocuments
directory. These documents appear in theFiles
app, and in a document browser. Users can open and edit these document in place.
Note that any item you save in the Documents
directory will be accessible.
Answered By - Andrew
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.