Project

s3gzip

0.0
No commit activity in last 3 years
No release in over 3 years
Read and write gziped content in S3 without hitting disk.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1.34.0
~> 1.0.0
 Project Readme

s3gzip

Read and write gziped content in S3 without hitting disk.

Example

require 's3gzip'

id='S3_ACCESS_KEY_ID'
secret='S3_SECRET_ACCESS_KEY'

bucket='MY_BUCKET'
filename='a/folder/with/filename.gz'

S3Gzip::Writer.open(id, secret, bucket, filename) do |writer|
  writer.write 'some content, gzipped, then stored in s3.'
end

result = S3Gzip::Reader.read(id, secret, bucket, filename)

puts result
# Output:
# some content, gzipped, then stored in s3.

Methods

You can use S3Gzip::Writer in a variety of ways from a one-liner to many-liner. These three examples do the same thing:

require 's3gzip'

id = 'S3_ACCESS_KEY_ID'
secret = 'S3_SECRET_ACCESS_KEY'

bucket = 'MY_BUCKET'
filename = 'a/folder/with/filename.gz'
content = 'some content, gzipped, then stored in s3.'

writer = S3Gzip::Writer.new(id, secret, bucket, filename)
writer.write content
writer.close_and_send

S3Gzip::Writer.open(id, secret, bucket, filename) do |writer|
  writer.write content
end

S3Gzip::Writer.write(id, secret, bucket, filename, content)

When using the first method, close_and_send must be called. This is done automatically when using open or write class methods.

Also, please note that every time you write to the file on S3, it will overwrite the previous value. This is generally true with S3, but can be a bit confusing given S3's eventual consistency model. Read more about that in the AWS S3 FAQ.

Requirements/Dependencies

Copyright

Copyright © 2014 Troy Howard. See LICENSE for details.