You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
iOS: Implement security scope access (bookmark) for read and readDir #51
I can submit a PR to implement this feature but I would like to know which approach do you prefer?
Would it make sense to create "readDirBookmark" and "readBookmark" functions only available for iOS? then passing the base64 encoded iOS bookmark (this would allow the implementation to work easily with https://react-native-documents.github.io/docs/doc-picker-api#bookmarkingresponse)
I am strongly against specific-OS-only functions in RN libraries. This one has a bunch of them, but that is the legacy, I want to get rid of them all over time (though, it might take a while).
Re. bookmarks, I've added their support to pickFile(), copyFile(), and exists() methods some time ago (see #28, and the commit 2437f8e, in particular). I might not remember the exact details now, but I believe in TS layer bookmark URLs are handled just as regular URLs passed to the existing functions, and having the format bookmark://<BASE64_ENCODED_SCOPED_URL_DATA>, and on the native side, in iOS code, there is already pathToUrl() method that, if passed such string, correctly restores the original bookmark URL, which can be used to access scoped resources (and if passed a regular URL, it also handles it appropriately). So, essentially to support that in other functions, you should just ensure they pass URL they got through that pathToUrl() method, and may be a few other minor checks / code changes on top of that — just replicate what I did in that change I referred to. Unless I am missing anything here, then let's discuss if further.
I am strongly against specific-OS-only functions in RN libraries. This one has a bunch of them, but that is the legacy, I want to get rid of them all over time (though, it might take a while).
Re. bookmarks, I've added their support to pickFile(), copyFile(), and exists() methods some time ago (see #28, and the commit 2437f8e, in particular). I might not remember the exact details now, but I believe in TS layer bookmark URLs are handled just as regular URLs passed to the existing functions, and having the format bookmark://<BASE64_ENCODED_SCOPED_URL_DATA>, and on the native side, in iOS code, there is already pathToUrl() method that, if passed such string, correctly restores the original bookmark URL, which can be used to access scoped resources (and if passed a regular URL, it also handles it appropriately). So, essentially to support that in other functions, you should just ensure they pass URL they got through that pathToUrl() method, and may be a few other minor checks / code changes on top of that — just replicate what I did in that change I referred to. Unless I am missing anything here, then let's discuss if further.
Thanks for the quick reply and for all the details, that's exactly what I was expecting. I will try to replicate what you did for pickFile(), copyFile(), and exists() for the read and readDir with the bookmark scheme in the url. 👍
Presumably done for readDir() (though, I have not explicitly tested it with a bookmark, just refactored the code, and checked it still works for regular URLs).
Activity
birdofpreyru commentedon Jun 14, 2024
Hi @zenoxs , thanks for your interest!
I am strongly against specific-OS-only functions in RN libraries. This one has a bunch of them, but that is the legacy, I want to get rid of them all over time (though, it might take a while).
Re. bookmarks, I've added their support to
pickFile(),copyFile(), andexists()methods some time ago (see #28, and the commit 2437f8e, in particular). I might not remember the exact details now, but I believe in TS layer bookmark URLs are handled just as regular URLs passed to the existing functions, and having the formatbookmark://<BASE64_ENCODED_SCOPED_URL_DATA>, and on the native side, in iOS code, there is alreadypathToUrl()method that, if passed such string, correctly restores the original bookmark URL, which can be used to access scoped resources (and if passed a regular URL, it also handles it appropriately). So, essentially to support that in other functions, you should just ensure they pass URL they got through thatpathToUrl()method, and may be a few other minor checks / code changes on top of that — just replicate what I did in that change I referred to. Unless I am missing anything here, then let's discuss if further.zenoxs commentedon Jun 14, 2024
Thanks for the quick reply and for all the details, that's exactly what I was expecting. I will try to replicate what you did for
pickFile(),copyFile(), andexists()for thereadandreadDirwith the bookmark scheme in the url. 👍birdofpreyru commentedon Jun 15, 2024
Presumably done for
readDir()(though, I have not explicitly tested it with a bookmark, just refactored the code, and checked it still works for regular URLs).