问题
I have a nodejs program running in Heroku which gives me the URL of files. These files need to be stored in an s3 bucket.
It is my understanding that there is no way to upload a file from a url directly to an s3 bucket.
How would you suggest I get the files from the URL to the s3 bucket? I've seen talk of using an EC2 instance but would like to avoid that if possible. Is there anyway to do this using just heroku and S3?
回答1:
I understand this is tagged node-js
, but if someone needs this for Ruby here's how (Ruby AWS SDK v3):
obj = Aws::S3::Object.new(bucket_name: 'target-bucket', key: 'target-key')
obj.upload_stream do |write_stream|
IO.copy_stream(URI.open('http://example.com/file.ext'), write_stream))
end
来源:https://stackoverflow.com/questions/45947814/upload-file-from-url-to-s3-bucket