module Shrine::InstanceMethods

Direct including types

Defined in:

shrine.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(storage_key : String) #

[View source]

Instance Method Detail

def generate_location(io : IO | UploadedFile, metadata, **options) #

Generates a unique location for the uploaded file, preserving the file extension. Can be overriden in uploaders for generating custom location.


[View source]
def generate_uid(io) #

Generates a unique identifier that can be used for a location.


[View source]
def storage #

Returns the storage object referenced by the identifier.


[View source]
def storage_key : String #

[View source]
def upload(io : IO | UploadedFile, **options) #

The main method for uploading files. Takes an IO-like object and an optional context hash (used internally by Shrine::Attacher). It calls user-defined #process, and afterwards it calls #store. The io is closed after upload.

uploader.upload(io) uploader.upload(io, metadata: { "foo" => "bar" }) # add metadata uploader.upload(io, location: "path/to/file") # specify location uploader.upload(io, upload_options: { acl: "public-read" }) # add upload options


[View source]
def warn(message) #

Prints a warning to the logger.


[View source]