如何发送二进制多部分formdata为base64? [英] How to send binary multipart formdata as base64?

查看:518
本文介绍了如何发送二进制多部分formdata为base64?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能存在重复:


我有一个基于Java,Wicket和JQuery的Web应用程序,它具有使用户能够通过多部分/表单数据上传文件(图像,pdf,rtf)的功能。



我们的网络安全基础架构会过滤所有http流量,以撷取可能的恶意内容,例如XSS攻击,SQL注入,缓冲区溢出等。

过滤器不区分正常文本输入字段和文件数据,因此它从许多上传的二进制文件中获取误报,防止这些文件被上传。我无法更改安全策略。



似乎解决这个问题的最好办法是将文件数据编码为base-64,以便通过Content-Transfer -Encoding:base64类似于电子邮件客户端的功能。



有什么方法可以指导浏览器以base64或其他非二进制格式传输二进制文件吗?



如果没有,是否可以使用一些JavaScript手动完成?

解决方案

似乎你可以设置 Content-Transfer-Encoding:base64
来自W3C的
引用:



< blockquote>

如果该部分的值不符合默认(7BIT)编码,则可以对每个部分进行编码并提供Content-Transfer-Encoding标头。

http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2



提供Java Web服务器在使用不会参数 Content-Transfer-Encoding


Possible Duplicate:
How can you encode to Base64 using Javascript?

I have a web application based on Java, Wicket and JQuery which has a function to enable users to upload files (images, pdfs, rtf) through multipart/form-data.

Our web security infrastructure does filtering of all http traffic to pick up possibly malicious content e.g. XSS attacks, SQL injection, buffer overruns etc

The filter doesn't distinguish between normal text input fields and file data so it picks up false positives from many uploaded binary files, preventing those files from being uploaded. I cannot change the security policy.

It seems the best way around this would be for file data to be base-64 encoded so that it is sent with a Content-Transfer-Encoding:base64 similar to what email clients do.

Is there any way to direct the browser to transfer binary as base64 or some other non-binary format?

If not, could it be done manually with some JavaScript?

解决方案

It seems that you can set Content-Transfer-Encoding: base64
quote from W3C:

Each part may be encoded and the "Content-Transfer-Encoding" header supplied if the value of that part does not conform to the default (7BIT) encoding

http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2

Provided your Java Web Server in use doesn't ingore parameter Content-Transfer-Encoding.

这篇关于如何发送二进制多部分formdata为base64?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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