Upload image to webservice

Asked

Viewed 82 times

2

I am using the alamofire to post pro server, I wanted to know how to send an object that has an img inside it.

I saw the following excerpt to upload the image

  let fileURL = NSBundle.mainBundle().URLForResource("Default", withExtension: "png")
Alamofire.upload(.POST, "https://httpbin.org/post", file: fileURL)

but I still can’t figure out how to catch the fileURL

If someone can let me know if it is possible to send a complete object with photo or if I have to send it separately and how I get the fileURL

  • How so you want to send an object with an image inside? You can explain this better?

  • Where your image is stored. If Voce downloaded it probably Voce stored it in the Documents directory. If you are the case Voce you need to first create the url of the Documents directory and then just append the pathComponent to your url (filename).

1 answer

0

In a project I did, I read the file with pathForResource.

let filePath = NSBundle.mainBundle().pathForResource("Default", ofType:"png")

Browser other questions tagged

You are not signed in. Login or sign up in order to post.