使用cURL/libcurl上传到Amazon S3 [英] Uploading to Amazon S3 using cURL/libcurl
问题描述
我目前正在尝试开发一个应用程序,以使用cURL和c ++将文件上传到Amazon S3存储桶.仔细阅读《 S3开发人员指南》之后,我开始按照开发人员指南的说明使用cURL实施我的应用程序并形成Header,并经过大量试验和错误以确定创建S3签名的最佳方法之后,我现在面临501错误.收到的标头表明我正在使用的方法未实现.我不确定哪里错了,但这是我要发送给亚马逊的HTTP标头:
I am currently trying to develop an application to upload files to an Amazon S3 bucket using cURL and c++. After carefully reading the S3 developers guide I have started implementing my application using cURL and forming the Header as described by the Developers guide and after lots of trials and errors to determine the best way to create the S3 signature, I am now facing a 501 error. The received header suggests that the method I'm using is not implemented. I am not sure where I'm wrong but here is the HTTP header that I'm sending to amazon:
PUT /test1.txt HTTP/1.1
Accept: */*
Transfer-Encoding: chunked
Content-Type: text/plain
Content-Length: 29
Host: [BucketName].s3.amazonaws.com
Date: [Date]
Authorization: AWS [Access Key ID]:[Signature]
Expect: 100-continue
出于安全原因,我已经删除了存储桶名称,访问密钥ID和签名.
I have truncated the Bucket Name, Access Key ID and Signature for security reasons.
我不确定自己在做什么错,但由于接受"和传输编码"字段(不确定),我认为该错误正在生成.所以谁能告诉我我做错了什么或为什么我得到501.
I am not sure what I'm doing wrong but I think that the error is generating because of the Accept and Transfer-Encoding Fields (Not Really Sure). So can anyone tell me what I'm doing wrong or why I'm getting a 501.
推荐答案
已解决:我的代码中缺少CURLOPT作为文件大小,现在一切正常
Solved: was missing an CURLOPT for the file size in my code and now everything is working perfectly
这篇关于使用cURL/libcurl上传到Amazon S3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!