如何使用curl将大文件上传到amazon s3

时间:2016-01-22 09:22:18

标签: bash amazon-web-services curl amazon-s3

我使用这个bash脚本将一个相对较大的文件上传到AMAZON S3:

signature=`echo -en ${stringToSign} | openssl sha1 -hmac ${s3Secret} -binary | base64`
curl -m 6000 -S -v -X PUT -T "${file}" \
    -H "Host: ${bucket}.s3.amazonaws.com" \
    -H "Date: ${dateValue}" \
    -H "Content-Type: ${contentType}" \
    -H "Authorization: AWS ${s3Key}:${signature}" \
    https://${bucket}.s3.amazonaws.com/${file}

大部分时间它都能正常工作,但有时却无法给出这种错误:

[...]
28  768M    0     0   28  222M      0  8851k  0:01:28  0:00:25  0:01:03 7870k* SSL read: error:00000000:lib(0):func(0):reason(0), errno 104

30  768M    0     0   30  231M      0  9013k  0:01:27  0:00:26  0:01:01 9819k
* Closing connection 0
curl: (56) SSL read: error:00000000:lib(0):func(0):reason(0), errno 104

如何加载上传,直到加载没有错误?

curl -V

给出:

curl 7.46.0 (x86_64-redhat-linux-gnu) libcurl/7.46.0 OpenSSL/1.0.1e zlib/1.2.3 c-ares/1.10.0 libidn/1.18 libssh2/1.6.0
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSockets Metalink

它应该是最新版本。

0 个答案:

没有答案