Aws::S3::Client
Inherits Reference / Object
An S3 client for interacting with S3.
Creating an S3 Client
client = Client.new("region", "key", "secret")
Client with custom endpoint
client = Client.new("region", "key", "secret", endpoint: "http://test.com")
Client with custom signer algorithm
client = Client.new("region", "key", "secret", signer: :v2)
Constructors
Instance methods
Aborts a multi part upload. Returns true if the abort was a success, false otherwise.
client = Client.new("region", "key", "secret")
resp = client.abort_multipart_upload("bucket1", "obj", "123")
p resp # => true
Batch deletes a list of object keys in a single request.
client = Client.new("region", "key", "secret")
resp = client.batch_delete("bucket1", ["obj", "obj2"])
p resp.success? # => true
Complete a multipart upload
client = Client.new("region", "key", "secret")
resp = client.complete_multipart_upload("bucket1", "obj", "123", parts)
p resp.key # => obj
Delete a bucket, note: it must be empty
client = Client.new("region", "key", "secret")
resp = client.delete_bucket("test")
p resp # => true
Delete an object from a bucket, returns true if successful, false
otherwise.
client = Client.new("region", "key", "secret")
resp = client.delete_object("bucket1", "obj")
p resp # => true
Get the contents of an object in a bucket
client = Client.new("region", "key", "secret")
resp = client.get_object("bucket1", "obj")
p resp.body # => "MY DATA"
Get information about a bucket, useful for determining if a bucket exists.
Raises a Http::ServerError if the bucket does not exist.
client = Client.new("region", "key", "secret")
resp = client.head_bucket("bucket1")
p resp # => true
List s3 buckets
client = Client.new("region", "key", "secret")
resp = client.list_buckets
p resp.buckets.map(&.name) # => ["bucket1", "bucket2"]
List all the items in a bucket
client = Client.new("region", "key", "secret")
resp = client.list_objects("bucket1", prefix: "test")
p resp.map(&.key) # => ["obj"]
Create a bucket, optionally place it in a region.
client = Client.new("region", "key", "secret")
resp = client.create_bucket("test")
p resp # => true
Add an object to a bucket.
client = Client.new("region", "key", "secret")
resp = client.put_object("bucket1", "obj", "MY DATA")
p resp.key # => "obj"
Start a multipart upload
client = Client.new("region", "key", "secret")
resp = client.start_multipart_upload("bucket1", "obj")
p resp.upload_id # => someid
Upload a part, for use in multipart uploading
client = Client.new("region", "key", "secret")
resp = client.upload_part("bucket1", "obj", "someid", 123, "MY DATA")
p resp.upload_id # => someid