App-local file storage.
Provides a thin Elixir wrapper over the device filesystem using named
locations instead of raw paths. Basic file operations (list, stat,
delete, copy, move, read, write) are pure File.* calls —
no NIF overhead except for the initial dir/1 path resolution.
Locations
:temp— ephemeral; may be purged by the OS at any time:documents— persists across app sessions; user-visible on iOSwhen `UIFileSharingEnabled` is set (see `mix dala.enable`):cache— persists until OS needs space; not user-visible:app_support— persists, hidden from user, backed up on iOS
Platform-specific storage
See Dala.Storage.Apple and Dala.Storage.Android for saving to the native
photo/media library and accessing platform-specific directories.
Results
Operations that can fail return {:ok, value} | {:error, posix}.
dir/1 raises on an unknown location atom.
Summary
Functions
Append data to the end of a file.
Copy src to dest.
Create a new empty file at path.
Create a new file at path with the given content.
Delete a file or directory at path.
Resolve a location atom to its absolute path on the current device.
Ensure the parent directory for path exists, creating it if necessary.
Check if a file or directory exists at path.
Export a file from a location to a destination path.
Return the file extension including the leading dot, or "" if none.
Return detailed file information.
List all files in a location or an absolute path.
Move src to dest.
Read a file's contents as a binary.
Read a file and return its contents as a string.
Return the file size in bytes, or {:error, reason} if the file doesn't exist.
Return metadata for a file.
Update the contents of an existing file at path.
Write data to path.
Write content to a file as text.
Functions
Append data to the end of a file.
Creates the file if it doesn't exist.
Returns {:ok, path} on success.
Dala.Storage.append("/tmp/log.txt", "New log entry\n")
Copy src to dest.
dest may be a location atom (file is placed there keeping its basename)
or a full absolute path.
Returns {:ok, dest_path} on success.
Create a new empty file at path.
Creates parent directories if they don't exist.
Returns {:ok, path} on success.
Dala.Storage.create("/tmp/new_file.txt")
Create a new file at path with the given content.
Creates parent directories if they don't exist.
Returns {:ok, path} on success.
Dala.Storage.create("/tmp/new_file.txt", "Hello, World!")
Delete a file or directory at path.
Use force: true to delete non-empty directories.
Returns :ok on success.
Dala.Storage.delete("/tmp/old_file.txt")
Dala.Storage.delete("/tmp/old_dir", force: true)
Resolve a location atom to its absolute path on the current device.
Ensure the parent directory for path exists, creating it if necessary.
Returns :ok on success.
Dala.Storage.ensure_dir("/tmp/new_dir/file.txt")
Check if a file or directory exists at path.
Dala.Storage.exists?("/tmp/file.txt") #=> true
Export a file from a location to a destination path.
Creates parent directories of dest if needed.
Returns {:ok, dest_path} on success.
Dala.Storage.export("/tmp/file.txt", "/tmp/backup/file.txt")
Return the file extension including the leading dot, or "" if none.
No I/O — derived from the filename only.
Dala.Storage.extension("/tmp/clip.mp4") #=> ".mp4"
Dala.Storage.extension("/tmp/notes") #=> ""
Return detailed file information.
Returns a map with :name, :path, :size, :modified_at, :type,
and :extension.
Dala.Storage.info("/tmp/clip.mp4")
#=> %{name: "clip.mp4", path: "/tmp/clip.mp4", size: 204800,
# modified_at: ~U[2026-04-24 10:00:00Z], type: :regular,
# extension: ".mp4"}
List all files in a location or an absolute path.
Returns full paths, not just names.
Move src to dest.
dest may be a location atom (file is placed there keeping its basename)
or a full absolute path. Creates parent directories of dest if needed.
Returns {:ok, dest_path} on success.
Dala.Storage.move("/tmp/old.txt", "/tmp/new.txt")
Dala.Storage.move("/tmp/file.txt", :documents)
Read a file's contents as a binary.
Read a file and return its contents as a string.
Returns {:ok, content} on success.
Dala.Storage.read_text("/tmp/file.txt") #=> {:ok, "Hello"}
@spec size(String.t()) :: {:ok, non_neg_integer()} | {:error, atom()}
Return the file size in bytes, or {:error, reason} if the file doesn't exist.
Dala.Storage.size("/tmp/file.txt") #=> {:ok, 1024}
Return metadata for a file.
%{name: "clip.mp4", path: "/…/clip.mp4", size: 204_800,
modified_at: ~U[2026-04-24 10:00:00Z]}
Update the contents of an existing file at path.
Returns {:ok, path} on success. Returns {:error, :enoent} if the file
doesn't exist.
Dala.Storage.update("/tmp/existing_file.txt", "Updated content")
Write data to path.
Returns {:ok, path} on success.
Write content to a file as text.
Creates parent directories if they don't exist.
Returns {:ok, path} on success.
Dala.Storage.write_text("/tmp/file.txt", "Hello, World!")