AWS::S3::S3Object.url_for - How to do this with the new AWS SDK Gem?

前端 未结 5 1221
南笙
南笙 2020-12-14 16:04

I\'ve been using this forever with paperclip and aws-s3:

  def authenticated_url(style = nil, expires_in = 90.minutes)
      AWS::S3::S3Object.url_for(attach         


        
5条回答
  •  旧时难觅i
    2020-12-14 16:45

    Recently I upgraded to the newest gem for AWS SDK 2 for Ruby (aws-sdk-2.1.13) and getting pre-signed url has changed in this SDK version.

    The way of getting it:

    presigner = Aws::S3::Presigner.new
    presigner.presigned_url(:get_object, #method
                            bucket: 'bucket-name', #name of the bucket
                            key: "key-name", #key name
                            expires_in: 7.days.to_i #time should be in seconds
                            ).to_s
    

    You can find more info here: http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Presigner.html

提交回复
热议问题