FileStorage class

Nylo's file storage: named disks, the way Laravel's Storage facade works.

await FileStorage.disk('documents').put('reports/q3.pdf', pdfBytes);
await FileStorage.put('notes.txt', 'Hello'); // the default disk

disk('documents') is the short form. Five disks exist without any configuration (local, documents, cache, temp and assets); add or change them in lib/config/file_storage.dart, which is passed to nylo.configure(disks: ...).

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

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

defaultDisk → String
The name of the disk used when no name is given.
no setter
defaultDisks → Map<String, DiskConfig>
The disks every app starts with.
no setter
fakes → Map<String, FakeDisk>
The disks swapped for fakes, by name.
no setter
names → List<String>
The names of the configured disks.
no setter

Static Methods

allDirectories([String directory = '']) → Future<List<String>>
Disk.allDirectories on the default disk.
allFiles([String directory = '']) → Future<List<String>>
Disk.allFiles on the default disk.
append(String path, String text, {String separator = '\n'}) → Future<void>
Disk.append on the default disk.
build(DiskConfig config, {String name = 'on-demand'}) → Disk
A disk that isn't in the config; Laravel's Storage::build.
bytes(String path) → Future<Uint8List>
Disk.bytes on the default disk.
checksum(String path, {String algorithm = 'md5'}) → Future<String>
Disk.checksum on the default disk.
clearFakes() → void
Drops every fake; the next use of a faked disk starts empty.
configure({Map<String, DiskConfig>? disks, String? defaultDisk}) → void
Adds disks to the defaults, replacing any with the same name, and sets the defaultDisk.
copy(String from, String to) → Future<void>
Disk.copy on the default disk.
copyToDisk(String target, String path, [String? to]) → Future<void>
Disk.copyToDisk from the default disk.
delete(Object paths) → Future<bool>
Disk.delete on the default disk.
deleteDirectory(String path) → Future<bool>
Disk.deleteDirectory on the default disk.
directories([String directory = '']) → Future<List<String>>
Disk.directories on the default disk.
directoryExists(String path) → Future<bool>
Disk.directoryExists on the default disk.
disk([String? name]) → Disk
The disk named name, or the default disk.
download(String url, String path, {ProgressCallback? onProgress, CancelToken? cancelToken, Map<String, dynamic>? headers, Map<String, dynamic>? queryParameters}) → Future<void>
Disk.download on the default disk.
exists(String path) → Future<bool>
Disk.exists on the default disk.
fake([String? name]) → FakeDisk
Swaps the disk named name (or the default disk) for an empty in-memory FakeDisk, and returns it for assertions.
files([String directory = '']) → Future<List<String>>
Disk.files on the default disk.
get(String path) → Future<String>
Disk.get on the default disk.
json<T>(String path, {Map<Type, dynamic>? modelDecoders}) → Future<T?>
Disk.json on the default disk.
lastModified(String path) → Future<DateTime>
Disk.lastModified on the default disk.
list([String directory = '', bool recursive = false]) → Future<List<DiskEntry>>
Disk.list on the default disk.
makeDirectory(String path) → Future<void>
Disk.makeDirectory on the default disk.
mimeType(String path) → Future<String?>
Disk.mimeType on the default disk.
missing(String path) → Future<bool>
Disk.missing on the default disk.
move(String from, String to) → Future<void>
Disk.move on the default disk.
moveToDisk(String target, String path, [String? to]) → Future<void>
Disk.moveToDisk from the default disk.
path(String path) → Future<String>
Disk.path on the default disk.
prepend(String path, String text, {String separator = '\n'}) → Future<void>
Disk.prepend on the default disk.
prune({required Duration olderThan}) → Future<int>
Disk.prune on the default disk.
put(String path, Object contents) → Future<void>
Disk.put on the default disk.
putFile(String directory, Object file) → Future<String>
Disk.putFile on the default disk.
putFileAs(String directory, Object file, String name) → Future<String>
Disk.putFileAs on the default disk.
putJson(String path, Object? value) → Future<void>
Disk.putJson on the default disk.
readStream(String path) → Stream<List<int>>
Disk.readStream on the default disk.
reset() → void
Restores the default disks and drops every fake.
scope(String directory) → Disk
Disk.scope on the default disk.
size(String path) → Future<int>
Disk.size on the default disk.
url(String path) → Future<Uri>
Disk.url on the default disk.
usage() → Future<int>
Disk.usage on the default disk.
useFakes([bool enabled = true]) → void
When enabled, every writable disk becomes an in-memory FakeDisk on first use. NyTest.init() turns this on, so tests never write to the machine running them. Read-only disks such as assets stay real.