Expand description
§file-storage
This library aids in accessing file-like storage.
§Features & Dependencies
file-storage = "0.9.0"§Primary Features
tempfile # enables temporary local path creation
r2 # enables cloudflare r2 storage via the aws sdk (uses tokio)§Dependencies
This crate has no dependencies unless features are enabled.
§Usage
Paths are parsed with StoragePath::parse(path). The path format determines the file system — a
path starting with / uses the local Unix filesystem, C:\ uses Windows, and an R2 URL dispatches
to Cloudflare R2. All operations (read, write, delete, list_files, etc.) are called directly
on the path and dispatch to the correct backend automatically. No file system object or client needs
to be created or managed.
A StoragePath is split into a base path and a relative path. The base path identifies the root of
the file system (e.g. /, C:\, or https://account.r2.cloudflarestorage.com/bucket/). A path is
a FolderPath if it equals its base path or ends with the file separator, otherwise it is a
FilePath.
FilePath supports: exists, read, write, write_data, delete.
FolderPath supports: list_files, delete_files.
Structs§
- Error
- A storage path operation error.
- File
Path - A file path.
- Folder
Path - A folder path.
- Headers
- A set of HTTP headers.
- List
Files Op - A list-files operation.
- Local
List Files Op - A local list-files operation.
- Local
Path - A local storage path.
- Local
Read Op - A local read operation.
- Local
Write Op - A local write operation.
- R2List
Files Op - An R2 list-files operation.
- R2Path
- A Cloudflare R2 path.
- R2Read
Op - An R2 read operation.
- R2Write
Op - An R2 write operation.
- ReadOp
- A read operation.
- Storage
Path - A file or folder path.
- WriteOp
- A write operation.