Storage class
Storage facade on top of dox_storage.
Disks come from AppConfig.storage. Files are read as streams, so a
big file is never loaded into memory to send it.
String path = await Storage().put('images', bytes, extension: 'png');
return Storage().disk('s3').download(path);
Disk s3 = Storage().use('s3'); // full dox_storage API
Constructors
- Storage({DriveManager? manager})
-
manageris thedox_storageDriveManager. Default isDox().storage.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
delete(
String filename) → Future< void> - delete file from storage. a missing file is not an error.
-
disk(
String disk) → Storage - set the disk name
-
download(
String filename) → Future< DownloadableFile> - return the file as a download (Content-Disposition: attachment).
-
exists(
String filename) → Future< bool> - check the file exists in storage
-
get(
String filename) → Future< Uint8List?> - get stored file as bytes, or null when it does not exist. prefer stream or download to send a file.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
put(
String folder, List< int> bytes, {String? extension}) → Future<String> - store bytes with a new uuid file name and return its path. the extension is guessed from the bytes when not given.
-
putRequestFile(
String folder, RequestFile requestFile) → Future< String> - store the request file into storage, with a new uuid file name. a temp file on the local disk is moved, not read into memory.
-
signedUrl(
String filename, {Duration expiresIn = const Duration(minutes: 30)}) → Future< String> -
a URL that works for
expiresIn. For the local disk, serve it withRoute.files('files')and set the diskurlto that path. -
stream(
String filename) → Future< StreamFile> - return the file as a stream, from any disk.
-
toString(
) → String -
A string representation of this object.
inherited
-
url(
String filename) → Future< String> -
public URL of a file (needs
urlin the disk config) -
use(
[String? name]) → Disk -
The
dox_storagedisk, for the full API (copy, move, list, ...).
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited