使用 multipart/form-data 将文件上传到 aws s3 返回 RequestTimeout [英] Upload file using multipart/form-data to aws s3 returns RequestTimeout

查看:218
本文介绍了使用 multipart/form-data 将文件上传到 aws s3 返回 RequestTimeout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 multipart/form-data POST 请求上传文件.相同的请求适用于不同系统上的其他人,但不适用于我的 PC.我收到来自 s3 服务器的RequestTimeout,在超时期限内未读取或写入您与服务器的套接字连接.空闲连接将被关闭"错误.

I'm trying to upload a file using multipart/form-data POST request. The same request works for others on different systems, but not for my PC. I get "RequestTimeout, Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed" error from the s3 server.

我使用 ubuntu 16.04 和 curl 发送请求.还尝试了 curl 的 --data-binary 选项,结果相同.

I'm using ubuntu 16.04 and curl for sending the request. Also tried the --data-binary option for curl with the same results.

curl -X POST --header "Content-Type:multipart/form-data, boundary=xxxxxxxxxx" --data @x.txt http://some-server.s3.amazonaws.com  

x.txt 看起来像这样:

x.txt looks like this:

--xxxxxxxxxx
Content-Disposition: form-data; name="AWSAccessKeyId"

someaccesskey
--xxxxxxxxxx
Content-Disposition: form-data; name="success_action_status"

200
--xxxxxxxxxx
Content-Disposition: form-data; name="acl"

public-read
--xxxxxxxxxx
Content-Disposition: form-data; name="key"

/somedir/somefilename.png
--xxxxxxxxxx
Content-Disposition: form-data; name="Cache-Control"

no-cache
--xxxxxxxxxx
Content-Disposition: form-data; name="Content-Type"

image/png
--xxxxxxxxxx
Content-Disposition: form-data; name="policy"

somepolicy==
--xxxxxxxxxx
Content-Disposition: form-data; name="signature"

somesignature=
--xxxxxxxxxx
Content-Disposition: form-data; name="file"; filename="somefilename.png"
Content-Type: application/octet-stream

S
--xxxxxxxxxx--

推荐答案

在 Wireshark 中查看从我的机器退出的数据包后,我发现 Windows 减少了它尝试发送到 Amazon 的数据包的长度,Ubuntu 保留了它作为MTU 1500,手动改成536后,数据包通过了.

After viewing the exiting packets from my machine in Wireshark I've found that Windows reduces the length of a packet that it tries to send to Amazon, Ubuntu left it as the MTU 1500, after manualy changing it to 536, the packet got through.

这篇关于使用 multipart/form-data 将文件上传到 aws s3 返回 RequestTimeout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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