-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement security scoped url with bookmark for readDir on iOS #52
implement security scoped url with bookmark for readDir on iOS #52
Conversation
Looks fine. Will double-check it does not break tests in the Example App and release shortly. Are you using a 3rd part library to get the bookmark because |
Well... it turned out your PR even did not compile; and when looking into it closely I figured out that |
Sadly, I am using the premium version of this lib. There is actually no free react native lib that allows selecting a folder. I think it's not that hard to implement, but it would probably easier to do in swift rather than objectif c. EDIT: Nvm, it looks like you can simply edit the the pickFile method on picker = [[UIDocumentPickerViewController alloc]
// Add the following line
initWithDocumentTypes:@[(NSString *)kUTTypeFolder]
inMode:UIDocumentPickerModeOpen]; then on the App.tsx of the example: const res = await pickFile();
if (res.length > 0 && res[0]) {
const items = await readDir(res[0]);
console.log(items);
} I tried on my own and it returns a correct bookmark for the picked directory, and I can then list its content with the |
Sorry for that, that's really weird. I tested my branch on simulator and real device. I also patched the lib with the same code on my application and everything works as expected. Could you describe what error you got on compilation ? And which version of xcode you are using ? |
You did the following, and NSString *path = [dirUrl stringByAppendingPathComponent:obj]; Then, even it has other means to turn an
Yeah, that is about what I thought. Actually, there might be no need to edit anything, see how react-native-fs/ios/ReactNativeFs.mm Lines 1214 to 1220 in ef41f0b
I guess, there might be a MIME string (to be checked in iOS documentation) denoting a directory, which you can pass in on TS side, to automatically get |
Implement security scoped url with bookmark for
readDir
on iOS (more info: https://developer.apple.com/documentation/uikit/view_controllers/providing_access_to_directories)The function now accept a
bookmark://
scheme following by the iOS bookmark in base64.Example of usage with the @react-native-documents/picker librairie to pick up the bookmark of a folder on iOS:
NB: I was not sure on how to handle the exception for readDir function, feel free to edit my PR or add comments :)
Related to: #51