class AWS::S3::Client

Defined in:

s3.cr

Constant Summary

MAXIMUM_PART_COUNT = 10000

Part numbers must be in 1..MAXIMUM_PART_COUNT.

MINIMUM_PART_SIZE = (5 * 1024) * 1024

S3 requires every part of a multipart upload except the last to be at least this large.

SERVICE_NAME = "s3"

Instance Method Summary

Instance methods inherited from class AWS::Client

delete(path : String, headers = HTTP::Headers.new) delete, get(path : String, headers = HTTP::Headers.new)
get(path : String, headers = HTTP::Headers.new, &block : HTTP::Client::Response -> )
get
, head(path : String, headers : HTTP::Headers) head, post(path : String, body : String, headers = HTTP::Headers.new) post, put(path : String, body : IO, headers = HTTP::Headers.new) put

Constructor methods inherited from class AWS::Client

new(access_key_id : String = AWS.access_key_id, secret_access_key : String = AWS.secret_access_key, region : String = AWS.region, endpoint : URI = URI.parse("https://#{service_name}.#{region}.amazonaws.com"), session_token : Nil | String = AWS.session_token) new

Macros inherited from class AWS::Client

service_name service_name

Instance Method Detail

def abort_multipart_upload(bucket_name : String, key : String, upload_id : String) #

Cancels the upload and frees the storage used by its parts. Parts still being uploaded when this is called may survive, so it is worth calling again if any uploads were in flight.


[View source]
def abort_multipart_upload(upload : MultipartUpload) #

[View source]
def complete_multipart_upload(bucket_name : String, key : String, upload_id : String, parts : Enumerable(MultipartUpload::Part)) : CompleteMultipartUploadResult #

Assembles the uploaded parts into the final object. Parts are assembled in ascending part number order regardless of the order given here, and any uploaded parts left out of parts are discarded.


[View source]
def complete_multipart_upload(upload : MultipartUpload, parts : Enumerable(MultipartUpload::Part)) : CompleteMultipartUploadResult #

[View source]
def create_multipart_upload(bucket_name : String, key : String, headers my_headers : HTTP::Headers = HTTP::Headers.new) : MultipartUpload #

Starts a multipart upload. Every part is then sent with #upload_part and the object is assembled with #complete_multipart_upload. Object metadata such as Content-Type is set here, not on the parts.


[View source]
def delete_object(bucket_name : String, key : String) #

[View source]
def get_object(bucket_name : String, key : String, io : IO) : Nil #

[View source]
def get_object(bucket : Bucket, key : String) #

[View source]
def get_object(bucket_name : String, key : String) : String #

[View source]
def head_object(bucket : Bucket, key : String) #

[View source]
def head_object(bucket_name : String, key : String) #

[View source]
def list_buckets #

[View source]
def list_objects(bucket : Bucket, continuation_token : String | Nil = nil) #

[View source]
def list_objects(bucket_name : String, continuation_token : String | Nil = nil) #

[View source]
def list_parts(upload : MultipartUpload, part_number_marker : Int | Nil = nil, max_parts : Int | Nil = nil) : ListPartsResult #

[View source]
def list_parts(bucket_name : String, key : String, upload_id : String, part_number_marker : Int | Nil = nil, max_parts : Int | Nil = nil) : ListPartsResult #

Lists the parts uploaded so far, which is how a client that lost track of an upload in progress can resume it. Results are paginated: when truncated? is set, pass next_part_number_marker back in as part_number_marker to get the next page.


[View source]
def multipart_upload(bucket_name : String, key : String, body : IO, headers : HTTP::Headers = HTTP::Headers.new, part_size : Int = MINIMUM_PART_SIZE) : CompleteMultipartUploadResult #

Uploads body as a multipart upload, reading it part_size bytes at a time and never holding more than one part in memory. This is the simplest way to upload something large or something that can't be rewound, such as a socket or a pipe.

headers are applied to the object the same way they are for #put_object. If anything goes wrong after the upload has been created, it is aborted so S3 does not keep billing for the orphaned parts, and the original error is re-raised.


[View source]
def presigned_url(method : String, bucket_name : String, key : String, ttl = 10.minutes, headers = HTTP::Headers.new) #

Returns a URL that lets anyone holding it perform method on the object until ttl elapses. Any headers given are part of the signature, so the client using the URL must send them exactly.


[View source]
def put_object(bucket_name : String, key : String, headers my_headers : HTTP::Headers, body : IO) #

[View source]
def put_object(bucket_name : String, key : String, headers : HTTP::Headers, body : String) #

[View source]
def upload_part(bucket_name : String, key : String, upload_id : String, part_number : Int, body : String | Bytes, headers : HTTP::Headers = HTTP::Headers.new) : MultipartUpload::Part #

[View source]
def upload_part(bucket_name : String, key : String, upload_id : String, part_number : Int, body : IO, headers my_headers : HTTP::Headers = HTTP::Headers.new) : MultipartUpload::Part #

Uploads one part of a multipart upload. Parts are numbered from 1 and can be uploaded in any order, concurrently, or more than once (the last upload of a given number wins).

The body must be rewindable so it can be hashed for the signature. If it is not an IO::Memory, you must set Content-Length in headers yourself, since S3 does not accept chunked uploads.


[View source]
def upload_part(upload : MultipartUpload, part_number : Int, body : IO, headers : HTTP::Headers = HTTP::Headers.new) : MultipartUpload::Part #

[View source]
def upload_part(upload : MultipartUpload, part_number : Int, body : String | Bytes, headers : HTTP::Headers = HTTP::Headers.new) : MultipartUpload::Part #

[View source]