In aws-s3, there is a method (AWS::S3::S3Object.stream) that lets you stream a file on S3 to a local file. I have not been able to locate a similar method in aws-sdk.
i.e. in aws-s3, I do:
File.open(to_file, "wb") do |file|
AWS::S3::S3Object.stream(key, region) do |chunk|
file.write chunk
end
end
The AWS::S3:S3Object.read method does take a block as a parameter, but doesn't seem to do anything with it.
Amazon Simple Storage Service (Amazon S3) is a web service that provides highly scalable cloud storage. Amazon S3 provides easy to use object storage, with a simple web service interface to store and retrieve any amount of data from anywhere on the web. The JavaScript API for Amazon S3 is exposed through the AWS.
Call the listBuckets method of the Amazon S3 service object to retrieve a list of your buckets. The data parameter of the callback function has a Buckets property containing an array of maps to represent the buckets. Display the bucket list by logging it to the console. // Load the AWS SDK for Node.
Get started quickly using AWS with the AWS SDK for Ruby. The SDK helps take the complexity out of coding by providing Ruby classes for many AWS services including Amazon S3, Amazon EC2, DynamoDB, and more.
The Oracle Cloud Infrastructure SDK for Ruby enables you to write code to manage Oracle Cloud Infrastructure resources.
The aws-sdk gem now supports chunked reads of objects in S3. The following example gives a demonstation:
s3 = AWS::S3.new
File.open(to_file, "wb") do |file|
s3.buckets['bucket-name'].objects['key'].read do |chunk|
file.write chunk
end
end
At this time, not officially. I found this thread in the official AWS Ruby forum:
Does the ruby aws gem support streaming download from S3. Quoting AWS staff:
Unfortunately there is not a good solution baked into the aws-sdk gem. We are looking into way we could make this much simpler for the end user.
There's sample code for downloading in chunks. You might want to have a look at that for inspiration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With