ayinala
ayinala

Reputation: 195

How to fetch the PDF file from device to be able to upload it from my application?

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

Answers (3)

Aswath Hasina
Aswath Hasina

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

Gourav Joshi
Gourav Joshi

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

Related Questions