开发者

Upload image data to web server from android camera

Here's what I'm trying to accomplish:

After user takes a picture with the android camera, I want to save the image onto my Ruby on Rails web application (like PicPlz or Instagram)

Approach 1: After user takes the picture, convert the byte开发者_JAVA技巧 array and save as .jpeg on the phone. Then upload the image file onto the server through a post request (Link here)

Approach 2: After user takes the picture, post the byte array data directly to my web application's web service, and then have the web application convert the byte array into an image file and save it onto the server

Question: Which approach is faster and more efficient?

I'm also open to suggestions for other approaches.

Thanks for your time and help :)


The answer is inexplicably the server, especially if you can get Image Magick installed on the box and convert the stream from the command line. I use PhP, but to my understanding running commands from Ruby is very similar and easy.

The phone... nine times out of ten is going to be running a whole lot of background apps and you will never be able to rely on it to do anything quickly. People install garbage on their phones and never clean it up just like they do there PC's and Laptops.


Approach 2 is better.
There is another approach that u can take.
- store the byte array into a temp file before u start sending it to the server.
- This makes sure that u don't lose the data even if there's a problem with the connection.
- Once the upload is complete, ur application can erase the temp file.
- One more advantage of this approach is that u can make sure that the user can make use of ur application, even when they are not connected to the internet.
- Once the user is connected u could ask them, n then start uploading to the server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜