trunk v0.0.1 Trunk.Storage.Filesystem
A Trunk.Storage
implementation for the local file system.
Link to this section Summary
Functions
Generates a URL for the storage directory and file
Deletes the file from the file system
Saves the file to the file system
Link to this section Functions
Link to this function
build_uri(directory, filename, opts \\ [])
Generates a URL for the storage directory and file
directory
- The relative directory where the file is savedfilename
- The name of the file that was previous savedopts
- The options for the storage systembase_url:
(optional) The base url to join the path to
Example:
Trunk.Storage.Filesystem.build_url("path/to", "file.ext")
#=> "path/to/file.ext"
Trunk.Storage.Filesystem.build_url("path/to", "file.ext", base_uri: "http://example.com")
#=> "http://example.com/path/to/file.ext"
Trunk.Storage.Filesystem.build_url("path/to", "file.ext", base_uri: "http://example.com/uploads/")
#=> "http://example.com/uploads/path/to/file.ext"
Trunk.Storage.Filesystem.build_url("path/to", "file.ext", base_uri: "/uploads/")
#=> "/uploads/path/to/file.ext"
Link to this function
delete(directory, filename, opts \\ [])
Deletes the file from the file system.
directory
- The relative directory within which to store the filefilename
- The name of the file to be savedopts
- The options for the storage systempath:
(required) The base path within which to save files
Example:
The file will be removed from /opts/uploads/path/to/file.ext
Trunk.Storage.Filesystem.delete("path/to/", "file.ext", path: "/opt/uploads")
Link to this function
save(directory, filename, source_path, opts \\ [])
Saves the file to the file system.
directory
- The relative directory within which to store the filefilename
- The name of the file to be savedsource_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 systempath:
(required) The base path within which to save files
Example:
The file will be saved to /opts/uploads/path/to/file.ext
Trunk.Storage.Filesystem.save("path/to/", "file.ext", "/tmp/uploaded_file.ext", path: "/opt/uploads")