Vinod Jadhav
Vinod Jadhav

Reputation: 1065

Upload pdf file from document directory to server in ios

How to Upload pdf file located in document directory to server.

Appreciate for help

Upvotes: 0

Views: 5190

Answers (1)

iOS
iOS

Reputation: 5470

SWIFT 2.0 : Use below code to convert pdf file to NSData. And use the POST service to upload the data to server.

    let documentDirectory = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0]
    var filePath = documentDirectory.stringByAppendingString("/")
    filePath     = filePath.stringByAppendingString("final.pdf")
    let pdfData  = NSData(contentsOfFile: filePath)

Here, "filePath" is the path of the pdf file in document directory with name "final.pdf".

Upvotes: 5

Related Questions