Module: Shrine::Plugins::KitheStorageLocation

Defined in:
lib/shrine/plugins/kithe_storage_location.rb

Overview

Set custom storage locations/paths for both the original file which is the main file in the shrine attachment at Asset#file, and any shrine derivatives.

Shrine’s default is to just put both of these at top-level ‘[randomID].suffix`. We instead:

## Original file

Stored at ‘asset/#asset_uuid_id/#unique_file_id.suffix` – regardless of asset sub-class, since they all have unique ids, just all under asset/. (In retrospect, maybe shoudl have left `asset/` off, and let consumer specify a prefix when configuring storage).

If no Asset pk is available (direct upload or unsaved Asset), will be stored just under “asset/#unique_file_id.#suffix”

We are choosing to store under Asset UUID PK instead of friendlier_id, friendlier_id is good for public URLs and UI, but actual PK is more reliable/immutable.

## Derivatives

Stored at ‘#asset_uuid_id/derivative_key/#unique_file_id.suffix`.

If asset uuid pk is not available, will raise a TypeError and refuse to store derivative. (This may have to be thought through more.)

If you want an additional prefix, supply it hwen configuring kithe_derivatives storage.

Defined Under Namespace

Modules: InstanceMethods