Module: PresignedUpload::Storage

Included in:
Uploadable
Defined in:
lib/presigned_upload/storage.rb

Overview

Storage module that provides a common interface for interacting with different storage adapters.

Examples:

class MyUploader
  include Storage
end

uploader = MyUploader.new
url = uploader.presigned_url('key', :put, 3600)
uploader.delete_file('key')

Instance Method Summary collapse

Instance Method Details

#delete_file(key) ⇒ Object

Deletes the file with the specified key from the storage.

Parameters:

  • key (String)

    The key or identifier of the file to be deleted.



31
32
33
# File 'lib/presigned_upload/storage.rb', line 31

def delete_file(key)
  adapter.delete_file(key)
end

#presigned_url(key, method, expires_in = 3600) ⇒ String

Generates a presigned URL for the specified key, HTTP method, and expiration time.

Parameters:

  • key (String)

    The key or identifier of the file in the storage.

  • method (Symbol)

    The HTTP method for which the presigned URL is generated (e.g., :put, :get).

  • expires_in (Integer) (defaults to: 3600)

    The duration in seconds for which the URL is valid (default is 3600 seconds).

Returns:

  • (String)

    The presigned URL for the specified key and method.



23
24
25
# File 'lib/presigned_upload/storage.rb', line 23

def presigned_url(key, method, expires_in = 3600)
  adapter.presigned_url(key, method, expires_in)
end