Skip to main content

Crate file_storage

Crate file_storage 

Source
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.
FilePath
A file path.
FolderPath
A folder path.
Headers
A set of HTTP headers.
ListFilesOp
A list-files operation.
LocalListFilesOp
A local list-files operation.
LocalPath
A local storage path.
LocalReadOp
A local read operation.
LocalWriteOp
A local write operation.
R2ListFilesOp
An R2 list-files operation.
R2Path
A Cloudflare R2 path.
R2ReadOp
An R2 read operation.
R2WriteOp
An R2 write operation.
ReadOp
A read operation.
StoragePath
A file or folder path.
WriteOp
A write operation.

Enums§

Operation
A path operation.
Reason
The reason for a path operation error.