Javascript 为具有公共访问权限的文件上载生成预签名URL

Javascript 为具有公共访问权限的文件上载生成预签名URL,javascript,amazon-web-services,amazon-s3,Javascript,Amazon Web Services,Amazon S3,我有一个默认ACL设置为private的bucket。我想生成预签名的url,并将其分发给用户,以便他们可以上传文件,上传后文件需要公开访问 我可以生成预签名的url并上传文件,但文件始终保持私有。如果在创建签名url时将ACL设置为“public read”,则getSignedUrl正在生成签名url,但对该签名url的PUT请求会导致访问被拒绝 var params = { Bucket: "bucket name", Key: "file key name", E

我有一个默认ACL设置为private的bucket。我想生成预签名的url,并将其分发给用户,以便他们可以上传文件,上传后文件需要公开访问

我可以生成预签名的url并上传文件,但文件始终保持私有。如果在创建签名url时将ACL设置为“public read”,则getSignedUrl正在生成签名url,但对该签名url的PUT请求会导致访问被拒绝

var params = {
    Bucket: "bucket name",
    Key: "file key name",
    Expires: 3600,
    ACL:"public-read",
    ContentType: "application/octet-stream"
};
s3.getSignedUrl("putObject", params);
bucket可以包含私有或公共可访问的文件,我想在创建签名url时设置隐私。我怎样才能做到这一点


我正在使用amazon javascript sdk。

这里来自AWS-S3文档

看来你得用很难的方法

getSignedUrl(operation, params, callback) ⇒ String?
Note: You must ensure that you have static or previously resolved credentials if you
call this method synchronously (with no callback), otherwise it may not properly sign
the request. If you cannot guarantee this (you are using an asynchronous credential provider,
i.e., EC2 IAM roles), you should always call this method with an asynchronous callback.
Note: Not all operation parameters are supported when using pre-signed URLs. Certain parameters,
such as SSECustomerKey, ACL, Expires, ContentLength, or Tagging must be provided as headers when
sending a request.
If you are using pre-signed URLs to upload from a browser and need to use these fields,
see createPresignedPost()....

这里来自AWS-S3文档

看来你得用很难的方法

getSignedUrl(operation, params, callback) ⇒ String?
Note: You must ensure that you have static or previously resolved credentials if you
call this method synchronously (with no callback), otherwise it may not properly sign
the request. If you cannot guarantee this (you are using an asynchronous credential provider,
i.e., EC2 IAM roles), you should always call this method with an asynchronous callback.
Note: Not all operation parameters are supported when using pre-signed URLs. Certain parameters,
such as SSECustomerKey, ACL, Expires, ContentLength, or Tagging must be provided as headers when
sending a request.
If you are using pre-signed URLs to upload from a browser and need to use these fields,
see createPresignedPost()....