从闪存发送大量数据时出现问题
我在从闪存发送巨大(~4MB)数据块到我的 java servlet 时遇到问题,目前我正在使用 URLVariables 传输数据,但是这似乎有一个限制(因为它似乎可以工作,与较小的数据块),我如何抑制此限制,或以任何其他方式将我的数据获取到我的 servlet。
到目前为止我的闪存代码:
var variables:URLVariables = new URLVariables();
variables.name = name_string; //Plenty of these small attributes
variables.data = data_string; //And the huge BLOB
var sendReq:URLRequest = new URLRequest("http://localhost:8080/recieve/");
sendReq.method = URLRequestMethod.POST;
sendReq.data = variables;
var sendLoader:URLLoader;
sendLoader = new URLLoader();
sendLoader.addEventListener(Event.COMPLETE, Handler);
sendLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
sendLoader.load(sendReq);
I'm having an issue sending a huge (~4MB) block of data from flash, to my java servlet, currently I'm transferring the data using URLVariables, however it seems there's a limit to this (because it seems to work, with smaller data blocks), how do I suppress this limit, or in any other way, get my data to my servlet.
My flash code so far:
var variables:URLVariables = new URLVariables();
variables.name = name_string; //Plenty of these small attributes
variables.data = data_string; //And the huge BLOB
var sendReq:URLRequest = new URLRequest("http://localhost:8080/recieve/");
sendReq.method = URLRequestMethod.POST;
sendReq.data = variables;
var sendLoader:URLLoader;
sendLoader = new URLLoader();
sendLoader.addEventListener(Event.COMPLETE, Handler);
sendLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
sendLoader.load(sendReq);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
首先,所有帖子方法在IE中的2000多个字符左右(8点以前的至下)失败。
接下来,
urlloader
:请参阅 flash/as3-同时urlloader.load()请求的数量有限制吗?那样发送。这将消除最大问题。
First, All POST methods fail at around 2000+ characters in IE (at-least prior to 8).
Next, there is a limit to the
URLLoader
: see Flash/AS3 - is there a limit to the number of simultaneous URLLoader.load() requests?If possible, try breaking your data up into smaller pieces and sending it that way. This will eliminate the maximum problems.
经过研究后,我之前的建议 FileReference 是一个坏主意,因为 BitmapData 是在内存中创建的。
我建议尝试 如何将 ByteArray(来自 Flash)和一些表单数据发送到 php?
After looking into it, my earlier suggestion, FileReference, is a bad idea given the BitmapData is created within memory.
I will suggest trying How can I send a ByteArray (from Flash) and some form data to php?
因此,在尝试了闪光灯之后,我想出了一个解决方案;
我只是将 data_string 分解为给定大小的子字符串,然后枚举这些子字符串,并使用 URLLoader 和 part_id 传输每个子字符串。
然后,子字符串的收集由服务器端的part_ids 完成。
So after playing around with flash, I came up with a solution;
I simply broke the data_string into sub-strings of a given size, then enumerating these, and transferring each of these using the URLLoader, along with a part_id.
The collection of the sub-strings is then done at server-side, by the part_ids.
这听起来更像是服务器端的问题。检查您的 java 环境设置并增加允许的最大 POST/请求大小。
将数据分成多个部分并分别发送的解决方案可能只能起作用,因为每个部分都小于服务器端的限制。
This sounds more like an issue on the server side. Check your java environment settings and increase the maximum allowed POST/Request size.
The solution of breaking the data into multiple parts and sending them separately probably only works because each part is smaller than the server-side limit.