简体   繁体   English

$ http.post文件大小限制? 当然看起来像

[英]$http.post File Size Limit? Sure looks like it

I am currently working on a project that is requiring me to use AngularJS's $http.post to upload Base64 encoded file contents to a server, where the file contents will be converted and saved to a remote repository. 我目前正在一个项目上,该项目要求我使用AngularJS的$http.post将Base64编码的文件内容上载到服务器,在该服务器上文件内容将被转换并保存到远程存储库。

The file that I am uploading is about 2.31 MB, yet after the server receives the file contents through the $http.post method, the file contents are only 68 K in size! 我上传的文件约为2.31 MB,但是服务器通过$http.post方法接收文件内容后,文件内容只有68 K! What happened? 发生了什么?

I am pretty sure that, because my file contents are in Base64 format, I am not having an issue with string termination due to embedded nulls, am I? 我非常确定,因为我的文件内容为Base64格式,由于嵌入的null,我不会出现字符串终止问题,是吗?

I am mostly wondering if there is a byte limit to the $http.post method. 我主要想知道$http.post方法是否有字节限制。 I havn't found my answer anywhere else. 在其他任何地方都找不到我的答案。

Should I chop my file contents up, tell the server that I am starting an upload, do multiple upload chucks to the server, and then tell the server when I am done? 我应该将文件内容切碎,告诉服务器我正在开始上传,是否向服务器添加了多个上传卡盘,然后在完成时告诉服务器?

Silly me... 愚蠢的我...

So, the entire 2.31 MB were coming across to the server, yet I was truncating the file contents by only allocating a buffer that was just under 65K, the max limit to a TCP/IP packet. 因此,整个2.31 MB都传到了服务器上,但是我仅通过分配刚低于65K(TCP / IP数据包的最大限制)的缓冲区来截断文件内容。 Simply enough, I just need to make my buffer size dynamic to the incoming packet, after the packet has been reconstructed. 简而言之,在重构数据包后,我只需要使缓冲区大小动态适应传入的数据包即可。 Thanks for all the help guys. 感谢所有帮助人员。

I'm quoting this from the third answer in this question : 我引用这个问题的第三个答案:

Maybe you have an & in your content variable. 内容变量中可能有一个&。 Then everything after that would be stripped after that. 然后,此后的所有内容都会被删除。

So maybe in the base64-encoded file, there's an & somewhere alone the 68000th character chopping off the rest of the file since it thinks there is another request attached. 因此,也许在以base64编码的文件中,第68000个字符单独位于& ,砍掉了文件的其余部分,因为它认为附加了另一个请求。

Something like: http://www.example.com?post=324b6bjgj5jhg&fgdhgtuhuf will present $_GET['post'] as 324b6bjgj5jhg rather than 324b6bjgj5jhg&fgdhgtuhuf . 像这样的东西: http://www.example.com?post=324b6bjgj5jhg&fgdhgtuhuf : http://www.example.com?post=324b6bjgj5jhg&fgdhgtuhuf $_GET['post'] 324b6bjgj5jhg 324b6bjgj5jhg&fgdhgtuhuf将提供$_GET['post']324b6bjgj5jhg而不是324b6bjgj5jhg&fgdhgtuhuf The & makes it think there's another variable. &使其认为还有另一个变量。 I know this is a GET request but I guess something similar could be happening in POST , too. 我知道这是一个GET请求,但我想POST也可能发生类似的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM