Base64 图像上传 VS 二进制图像上传?

2024-04-14移动开发问题
6

本文介绍了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 二进制图像上传?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

突出显示朗读文本(在 iPhone 的故事书类型应用程序中)
Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))...
2024-08-12 移动开发问题
9

Cocos2d - 对 CCSprite 应用 GLImageProcessing 效果
Cocos2d - apply GLImageProcessing effect to CCSprite(Cocos2d - 对 CCSprite 应用 GLImageProcessing 效果)...
2024-08-12 移动开发问题
10

如何在 COCOS2d Android 中使用 CClistview?
How can I use CClistview in COCOS2d Android?(如何在 COCOS2d Android 中使用 CClistview?)...
2024-08-12 移动开发问题
5

未找到 SpriteBuilder 图像文件
SpriteBuilder image file not found(未找到 SpriteBuilder 图像文件)...
2024-08-12 移动开发问题
8

如何在 spritebuilder-Cocos2d 3.2 中添加单独的 iPad 和 iPhone 图像
How to add seperate iPad and iPhone images in spritebuilder- Cocos2d 3.2(如何在 spritebuilder-Cocos2d 3.2 中添加单独的 iPad 和 iPhone 图像)...
2024-08-12 移动开发问题
4

带有大图像的Objective C iPad动画-使用什么方法?
Objective C iPad Animation with large images - What method to use?(带有大图像的Objective C iPad动画-使用什么方法?)...
2024-08-12 移动开发问题
10