Latch::Storage
Storage backends handle the actual persistence of uploaded files. Implementations must provide methods for uploading, retrieving, checking existence, and deleting files.
Instance methods
Deletes the file at the given location.
storage.delete("uploads/photo.jpg")
Does not raise if the file doesn't exist.
Returns whether a file exists at the given location.
storage.exists?("uploads/photo.jpg")
# => true
Moves a file from another location.
Opens the file at the given location and returns an IO for reading.
io = storage.open("uploads/photo.jpg")
content = io.gets_to_end
io.close
Raises Latch::FileNotFound if the file doesn't exist.
Uploads an IO to the given location (id) in the storage.
storage.upload(io, "uploads/photo.jpg")
storage.upload(io, "uploads/photo.jpg", metadata: {"filename" => "original.jpg"})