Latch::Storage::FileSystem
Inherits Latch::Storage / Reference / Object
Local filesystem storage backend. Files are stored in a directory on the local filesystem. Supports an optional prefix for organizing files.
Latch.configure do |settings|
settings.storages["cache"] = Latch::Storage::FileSystem.new(
directory: "uploads",
prefix: "cache"
)
settings.storages["store"] = Latch::Storage::FileSystem.new(
directory: "uploads"
)
end
Constants
DEFAULT_DIRECTORY_PERMISSIONS = File::Permissions.new(493)
DEFAULT_PERMISSIONS = File::Permissions.new(420)
Constructors
new(directory : String, prefix : String | Nil = nil, clean : Bool = true, permissions : File::Permissions = DEFAULT_PERMISSIONS, directory_permissions : File::Permissions = DEFAULT_DIRECTORY_PERMISSIONS)
SourceInstance methods
clean?
Sourcedirectory
Sourcedirectory_permissions
Sourceexpanded_directory
Returns the full expanded path including prefix.
storage.expanded_directory
# => "/app/uploads/cache"
Opens the file at the given location and returns an IO for reading.
Returns the full filesystem path for the given id.
storage.path_for("abc123.jpg")
# => "/app/uploads/abc123.jpg"
permissions
Sourceprefix
SourceUploads an IO to the given location (id) in the storage.