Module: PresignedUpload::Uploadable::Model
- Extended by:
- ActiveSupport::Concern
- Includes:
- PresignedUpload::Uploadable
- Defined in:
- lib/presigned_upload/uploadable.rb
Overview
The ‘Model` submodule extends ActiveSupport::Concern to provide upload-related functionality to ActiveRecord models.
Instance Method Summary collapse
-
#delete_stored_file ⇒ Object
Deletes the stored file associated with the model.
-
#store_path ⇒ String
Returns the file store path.
-
#upload_url ⇒ String?
Returns a presigned URL for uploading the file.
-
#url ⇒ String?
Returns a presigned URL for accessing the stored file.
Methods included from Storage
Instance Method Details
#delete_stored_file ⇒ Object
Deletes the stored file associated with the model.
68 69 70 |
# File 'lib/presigned_upload/uploadable.rb', line 68 def delete_stored_file delete_file(store_path) end |
#store_path ⇒ String
Returns the file store path.
The store path is constructed by combining the storage directory
with the `original_name` of the file. If `store_dir` is present, it is
included in the path. If `store_dir` is not present, then the file
will be saved in the root directory.
80 81 82 |
# File 'lib/presigned_upload/uploadable.rb', line 80 def store_path "#{store_dir.present? ? "#{store_dir}/" : ""}#{original_name}" end |
#upload_url ⇒ String?
Returns a presigned URL for uploading the file. Returns ‘nil` if the upload status is ’completed’.
60 61 62 63 64 |
# File 'lib/presigned_upload/uploadable.rb', line 60 def upload_url return if completed? presigned_url(store_path, :put) end |
#url ⇒ String?
Returns a presigned URL for accessing the stored file. Returns ‘nil` if the upload status is not ’completed’.
49 50 51 52 53 |
# File 'lib/presigned_upload/uploadable.rb', line 49 def url return unless completed? presigned_url(store_path, :get) end |