Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services S3预签名URL上传成功,但它';它是空的_Amazon Web Services_Curl_Amazon S3 - Fatal编程技术网

Amazon web services S3预签名URL上传成功,但它';它是空的

Amazon web services S3预签名URL上传成功,但它';它是空的,amazon-web-services,curl,amazon-s3,Amazon Web Services,Curl,Amazon S3,我尝试用curl通过预先签名的url将文件上传到S3。 当我运行以下命令时,它返回success ❯ curl -v -X PUT --upload-file [file directory] '[pre-sined url]' * Trying [port]... * TCP_NODELAY set * Connected to bucket-name.s3.region.amazonaws.com (ip address) port 443 (#0) * ALPN, offering h

我尝试用curl通过预先签名的url将文件上传到S3。
当我运行以下命令时,它返回success

❯ curl -v -X PUT --upload-file [file directory] '[pre-sined url]'
*   Trying [port]...
* TCP_NODELAY set
* Connected to bucket-name.s3.region.amazonaws.com (ip address) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: C=US; ST=Washington; L=Seattle; O=Amazon.com, Inc.; CN=*.region.amazonaws.com
*  start date: Nov  9 00:00:00 2019 GMT
*  expire date: Dec 10 12:00:00 2020 GMT
*  subjectAltName: host "bukcet-name.s3.region.amazonaws.com" matched cert's "*.s3.region.amazonaws.com"
*  issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert Baltimore CA-2 G2
*  SSL certificate verify ok.
> PUT [pre-signed url] HTTP/1.1
> Host: bukcet-name.s3.region.amazonaws.com
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Type: image/png
> Content-Length: 145701
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
* We are completely uploaded and fine
< HTTP/1.1 200 OK
< x-amz-id-2: hogehoge
< x-amz-request-id:hugahuga
< Date: Mon, 17 Feb 2020 08:09:01 GMT
< ETag: "hogehuga"
< Content-Length: 0
< Server: AmazonS3
<
* Connection #0 to host bukcet-name.s3.region.amazonaws.com left intact
* Closing connection 0
但它返回错误。

AccessDenied请求中存在未签名的头X amz acl

另外,我想知道我的预签名url在directry路径中没有文件名。它是正确的预签名url吗?

我生成预签名url的实现如下所示:

    req, _ := svc.PutObjectRequest(&s3.PutObjectInput{
        Bucket: aws.String(bucketName),
        Key:    aws.String(key),
    })
    url, err := req.Presign(expires)

是否需要在PutObjectInput结构中添加ACL?

此问题通过在生成时在s3目录的末尾添加文件名来解决

例如(Golang):

    req, _ := svc.PutObjectRequest(&s3.PutObjectInput{
        Bucket: aws.String(bucketName),
        Key:    aws.String(key),
    })
    url, err := req.Presign(expires)

    req, _ := svc.PutObjectRequest(&s3.PutObjectInput{
        Bucket: aws.String("hogehoge/fugafuga/filename"),
        Key:    aws.String(key),
    })
    url, err := req.Presign(expires)