Good practices for uploading images through a restful API

I'm using Amazon S3 in my restful service to upload images. The restful service is being accessed by a iPhone app. I'm trying to figure what will be the best approach to upload the images.

Option 1: Use a multipart form data to upload the image and also include the JSON itself as another multipart in the HTTP request.

Option 2: a. Upload the image directly to Amazon S3 and get the URL back. b. Send a restful request with the JSON including the image URL.

Which approach would you choose?


I go for Option 1 as it is one request. It is better than 2 separate round trips (in Option 2).

链接地址: http://www.djcxy.com/p/48656.html

上一篇: 相当于java的OutputStream的python?

下一篇: 通过一个平静的API上传图片的好习惯