5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

s3 へPOSTでファイルをアップロードする(AWS SDK for RubyでPOSTパラメタを組み立てる)

Last updated at Posted at 2016-04-06

SDKを使うと簡単にPOSTできる

s3upload_presigned_post.rb
require "aws-sdk-resources"
require "net/http"

target_file = "test.txt"
s3 = Aws::S3::Resource.new(region: "ap-northeast-1")

obj = s3.bucket("mybucket").object(target_file)
presigned = obj.presigned_post(server_side_encryption: "AES256")

cmd = "curl -v -X POST"
presigned.fields.each do |k, v|
  cmd << " -F \"#{k}=#{v}\""
end
cmd << " -F file=@#{target_file}"
cmd << " "
cmd << presigned.url

puts cmd
puts `#{cmd}`
5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?