Base64 image upload VS Binary image upload?(Base64 图像上传 VS 二进制图像上传?)
问题描述
我希望我的移动应用程序能够将图像上传到我的服务器,在我的情况下,它是带有 nginx 的 Rails 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 二进制图像上传?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Base64 图像上传 VS 二进制图像上传?


- Android - 拆分 Drawable 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01