class Shrine::Storage::S3

Defined in:

shrine/storage/s3.cr

Constructors

Instance Method Summary

Instance methods inherited from class Shrine::Storage::Base

clean(path : String) clean, clean? : Bool clean?, delete(id : String) delete, exists?(id : String) : Bool exists?, open(id : String, **options) : IO open, upload(io : IO | UploadedFile, id : String, move = false, **options) upload, url(id : String, **options) : String url

Constructor Detail

def self.new(bucket : String, client : Awscr::S3::Client | Nil, prefix : String | Nil = nil, upload_options : Hash(String, String) = Hash(String, String).new, public : Bool = false) #

Initializes a storage for uploading to S3. All options are forwarded to [Shrine::Storage::S3#initialize], except the following:

:bucket : (Required). Name of the S3 bucket.

:client : By default an Awscr::S3::Client instance is created internally from additional options, but you can use this option to provide your own client.

:prefix : "Directory" inside the bucket to store files into.

:upload_options : Additional options that will be used for uploading files.

:public : Sets public access to all uploading files.


[View source]

Instance Method Detail

def bucket : String #

[View source]
def clean(path) #

[View source]
def client : Awscr::S3::Client #

[View source]
def delete(id : String) : Bool #

Delets the file, and by default deletes the containing directory if it's empty.


[View source]
def exists?(id : String) : Bool #

Returns true if the file exists on the S3.


[View source]
def object_key(id : String) : String #

Returns object key with potential prefix.


[View source]
def open(id : String, **options) : IO #

Returns a IO object from S3


[View source]
def path(id : String) #

[View source]
def public? : Bool #

[View source]
def upload(io : IO | UploadedFile, id : String, metadata : Shrine::UploadedFile::MetadataType, move = false, **upload_options) #

[View source]
def upload(io : IO | UploadedFile, id : String, move = false, **upload_options) #

Copies the file into the given location.


[View source]
def url(id : String, **options) : String #

Returns the presigned URL to the file.


[View source]