dszn2485 2018-08-13 02:32
浏览 118

具有公共访问权限的AWS Go SDK S3上传

I've been trying to upload an object to S3 with public access but I haven't been able to do it.

I am getting this error: InvalidArgument: Argument format not recognized status code: 400

Here is my code:

bucketName := "test-bucket"
key2 := "test.zip"
upParams := &s3manager.UploadInput{
    Bucket: &bucketName,
    Key:    &key2,
    Body:   response.Body,
    GrantRead: aws.String("uri:http://acs.amazonaws.com/groups/global/AllUsers"),
}

sess := session.Must(session.NewSession())

uploader := s3manager.NewUploader(sess)

_, err = uploader.Upload(upParams)
  • 写回答

1条回答 默认 最新

  • duanliang1898 2018-08-13 14:51
    关注

    Try ACL : "public-read" instead

    bucketName := "test-bucket"
    key2 := "test.zip"
    upParams := &s3manager.UploadInput{
        Bucket: &bucketName,
        Key:    &key2,
        Body:   response.Body,
        ACL: "public-read",
    }
    
    sess := session.Must(session.NewSession())
    
    uploader := s3manager.NewUploader(sess)
    
    _, err = uploader.Upload(upParams)
    
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab求解平差
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?