Sha256: d47684723735c5ac6f984412822a6bb58f5b97bc3786f92cffddd1bc6bfa3fa8

Contents?: true

Size: 914 Bytes

Versions: 2

Compression:

Stored size: 914 Bytes

Contents

$:<< 'lib'

require 'jets3t'

module JetS3t
  AWS_SECRET_PATH = '~/.awssecret'.freeze
  raise "#{AWS_SECRET_PATH} not found" unless File.exist?(File.expand_path(AWS_SECRET_PATH))

  access_key_id, secret_access_key = File.readlines(File.expand_path(AWS_SECRET_PATH)).map(&:chomp)
  credentials = AWSCredentials.new(access_key_id, secret_access_key)
  s3_service = RestS3Service.new(credentials)

  BUCKET_NAME = 'test-bucket-12345'
  # test_bucket = s3_service.create_bucket(BUCKET_NAME, Location::EUROPE)
  test_bucket = s3_service.bucket(BUCKET_NAME)

  # # simple string data
  # data = "Hello World!"
  # test_bucket.put('test/hello/world/hello_world.txt', data)
  
  FILE_NAME = '/tmp/hello_world.file'
  PATH = 'one/two/hello_world.txt'
  File.open(FILE_NAME, 'w') {|f| f.write('Hello World!') }
  file = File.new(FILE_NAME)
  test_bucket.put(PATH, file)

  object = test_bucket.get(PATH)
  p object.data
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jets3t-rb-1.0.1 examples/s3.rb
jets3t-rb-1.0.0 examples/s3.rb