trunk v0.0.7 Trunk.Storage behaviour View Source
This is a behaviour that can be implemented by any storage module to make sure it supports all required functions.
Link to this section 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)
Link to this section Types
Link to this section 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
MyStorage.delete("path/to/", "file.ext", some: :opt)
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
MyStorage.save("path/to/", "file.ext", "/tmp/uploaded_file.ext", some: :opt)