Reputation: 195
I'm working on an application, Where it has a feature that allows users to upload(& downloading the uploaded ones) the images from gallery to server. Now I should be able to upload the PDF files from the device as well. How can I fetch the PDF files from iCloud? No clue on how to proceed.
Any help would be appreciated.
Upvotes: 3
Views: 2522
Reputation: 195
UIDocumentPicker is the solution what I'm looking for https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/DocumentPickerProgrammingGuide/Introduction/Introduction.html
Upvotes: 3
Reputation: 140
You cannot access the PDF files or any document unless until it is in your app's Sandbox. You can access user's gallery and upload images to the server.
If the file is in your Documents directory(sandbox) you can proceed with the following code.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
Append your file path to this documentsDirectory string and fetch it.
In case if your pdf file is in your app's bundle,
NSString *pdfFilePath = [[NSBundle mainBundle] pathForResource:@"pdfFileName" ofType:@"pdf"];
Hope it helps.
Upvotes: 0
Reputation: 2419
First, PDF files are accessible from apps documents or library. You have to check apps document directory and fetch the pdf files. Apart from these If you want to save the PDF file you have to download it and save in apps documents directory.
Upvotes: 1