0

I am unable to upload a file (an mp4) to my server. I control the server and use an npm library parse the request. Now, when I use Postman and select a test mp4 to upload to my server, I successfully receive it. Yet when using this function from Alamofire, I receive nothing.

Alamofire.upload(fileURL, to: "http://localhost/video").responseJSON { response in debugPrint(response) } 

I send back some JSON in the response and successfully receive it in my app. No errors on either side. What am I missing?

5
  • 1
    Have you tried using multipartFormData with mimeType? Commented Apr 12, 2018 at 3:55
  • I've not read that thats necessary and see upload(fileURL:) and so I'd expect that to work. I tried multipartFormData but got an ill formed url error. Commented Apr 12, 2018 at 3:58
  • 1
    multipartFormData worked. thanks! Commented Apr 12, 2018 at 4:20
  • Glad to be of help Commented Apr 12, 2018 at 4:24
  • try this Commented Apr 12, 2018 at 4:55

1 Answer 1

2

Use MultiFormData to upload the image

Alamofire.upload( multipartFormData: { multipartFormData in multipartFormData.append(fileUrl, withName: "fileName") }, to: "http://localhost/video").responseJSON { response in debugPrint(response) }) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.