Sha256: 176bc042502e29620b6793aa45f64a5323886ef396d47b88381590838b4fa613

Contents?: true

Size: 760 Bytes

Versions: 7

Compression:

Stored size: 760 Bytes

Contents

# frozen_string_literal: true

require_relative "../lib/zip_kit"

# Any writable object can be used as a destination for the Streamer.
# For example, you can write to an S3 bucket. Newer versions of the S3 SDK
# support a method called `upload_stream` which allows streaming uploads. The
# SDK will split your streamed bytes into appropriately-sized multipart upload
# parts and PUT them onto S3.
bucket = Aws::S3::Bucket.new("mybucket")
obj = bucket.object("big.zip")
obj.upload_stream do |write_stream|
  ZipKit::Streamer.open(write_stream) do |zip|
    zip.write_file("large.csv") do |sink|
      CSV(sink) do |csv|
        csv << ["Line", "Item"]
        20_000.times do |n|
          csv << [n, "Item number #{n}"]
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
zip_kit-6.3.1 examples/s3_upload.rb
zip_kit-6.3.0 examples/s3_upload.rb
zip_kit-6.2.2 examples/s3_upload.rb
zip_kit-6.2.1 examples/s3_upload.rb
zip_kit-6.2.0 examples/s3_upload.rb
zip_kit-6.0.1 examples/s3_upload.rb
zip_kit-6.0.0 examples/s3_upload.rb