我现在正在尝试实现读取S3文件(mp4)的uri并放入rails服务器的函数。
def self.download
uri = 'https://s3.amazonaws.com/tokbox.com.archive2/45550892%2F324cad13-b447-4d3c-9477-c829665c8180%2Farchive.mp4?forprivacytherestofaddressisnotshownhere'
contents = URI.parse(uri)
File.open('testtest.mp3', 'wb') do |f|
f.write contents.read
end
end
但不幸的是,我现在看到以下错误。
OpenURI::HTTPError: 403 Forbidden
from /Users/sungpah/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/open-uri.rb:353:in `open_http'
from /Users/sungpah/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/open-uri.rb:724:in `buffer_open'
from /Users/sungpah/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/open-uri.rb:210:in `block in open_loop'
from /Users/sungpah/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/open-uri.rb:208:in `catch'
from /Users/sungpah/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/open-uri.rb:208:in `open_loop'
from /Users/sungpah/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/open-uri.rb:149:in `open_uri'
from /Users/sungpah/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/open-uri.rb:704:in `open'
from /Users/sungpah/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/open-uri.rb:712:in `read'
from (irb):9:in `block in irb_binding'
from (irb):8:in `open'
from (irb):8
我试图解析uri,或者把它变成字符串,但它还没有和我合作。 我希望听到任何好主意或预感向前推进!!!
最佳