View Source Trunk.Storage behaviour (trunk v1.5.1)
This is a behaviour that can be implemented by any storage module to make sure it supports all required functions.
Summary
Callbacks
Generates a URL to the S3 object
Deletes the version file from the storage system at path Path.join(directory, filename)
Save the source_file
to the storage system on path Path.join(directory, filename)
Types
@type opts() :: Keyword.t()
Callbacks
Generates a URL to the S3 object
directory
- The directoryfilename
- The name of the fileopts
- The options for the storage system, set in Trunk option:storage_opts
Example:
MyStorage.build_url("path/to", "file.ext", some: :opt)
#=> "https://my-storage/my-bucket/path/to/file.ext"
Deletes the version file from the storage system at path Path.join(directory, filename)
directory
- The directoryfilename
- The name of the fileopts
- The options for the storage system, set in Trunk option:storage_opts
Example:
The file should be removed from <storage system>/my-bucket/path/to/file.ext
MyStorage.delete("path/to/", "file.ext", some: :opt)
@callback save( directory :: String.t(), filename :: String.t(), source_path :: String.t(), opts() ) :: :ok | {:error, any()}
Save the source_file
to the storage system on path Path.join(directory, filename)
directory
- The directoryfilename
- The name of the filesource_path
- The full path to the file to be stored. This is a path to the uploaded file or a temporary file that has undergone transformationopts
- The options for the storage system, set in Trunk option:storage_opts
Example:
The file should be saved to <storage system>/my-bucket/path/to/file.ext
MyStorage.save("path/to/", "file.ext", "/tmp/uploaded_file.ext", some: :opt)