Reputation: 1065
How to Upload pdf file located in document directory to server.
Appreciate for help
Upvotes: 0
Views: 5190
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