Base64 图像上传 VS 二进制图像上传? [英] Base64 image upload VS Binary image upload?

查看:34
本文介绍了Base64 图像上传 VS 二进制图像上传?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的移动应用程序能够将图像上传到我的服务器,在我的情况下,它是带有 nginxRails 3.2.11.

I want my mobile application to be able to upload an image to my server, in my case it's a Rails 3.2.11 with nginx.

我阅读了很多关于 Base64 在客户端编码然后在服务器端解码的信息.

I read alot about Base64 encoding on client side and then decoding on the server side.

为什么不在 http 请求上使用 binary 上传和 multipart 标头?

Why not just use binary upload with multipart headers on the http request?

每种技术是否有任何优点/缺点?

推荐答案

Base64 将您的数据转换为二进制数据的 ASCII 表示.它允许您将数据嵌入到文本流中,例如 JSON.Base64 将传输的数据大小增加了 33%.

Base64 converts your data to an ASCII representation of the binary data. It allows you to embed your data in text streams such as JSON for example. Base64 increases the size of the data transferred by 33%.

multipart/form-data 是在 HTTP 请求中传输二进制数据的标准方式.它允许您为要传输的每个部分使用特定的编码/内容类型.在我看来,除非您有特定要求或设备/SDK 功能,否则您应该坚持分段上传.

multipart/form-data is the standard way of transferring binary data in HTTP requests. It allows you to use specific encodings / content types for each part you'd like to transfer. In my opinion, you should stick to multipart uploads unless you have specific requirements or device/SDK capabilities.

这篇关于Base64 图像上传 VS 二进制图像上传?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆