I use this code to send authenticated clients the URL to their S3 file. I believe this is the "presigned URL" that you're asking about. I haven't used this code for a PUT, so I'm not exactly sure if it's right for you, but it might get you close.
I know this is an older question, but I was wondering the same thing and found an elegant solution in the AWS S3 Documentation.
我知道这是一个较旧的问题,但我想知道同样的事情,并在AWS S3文档中找到了一个优雅的解决方案。
require 'net/http'
file = "somefile.ext"
url = URI.parse(presigned_url)
Net::HTTP.start(url.host) do |http|
http.send_request("PUT", url.request_uri, File.read(file), {"content-type" => "",})
end
This worked great for my Device Farm uploads.
这对我的Device Farm上传非常有用。
#4
0
Does anything on the s3 library page cover what you need? There are loads of examples there.
s3库页面上有什么内容可以满足您的需求吗?那里有很多例子。
#5
0
There are some generic REST libraries for Ruby; Google for "ruby rest client". See also HTTParty.
Ruby有一些通用的REST库;谷歌为“红宝石休息客户”。另见HTTParty。
#6
-5
I've managed to sort it out. Turns out the HTTP:Net in Ruby is has some short comings. Lot of Monkeypatch later I got it working.. More details when I have time. thank