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.allDirectorieson the default disk. -
allFiles(
[String directory = '']) → Future< List< String> > -
Disk.allFileson the default disk. -
append(
String path, String text, {String separator = '\n'}) → Future< void> -
Disk.appendon 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.byteson the default disk. -
checksum(
String path, {String algorithm = 'md5'}) → Future< String> -
Disk.checksumon 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
disksto the defaults, replacing any with the same name, and sets thedefaultDisk. -
copy(
String from, String to) → Future< void> -
Disk.copyon the default disk. -
copyToDisk(
String target, String path, [String? to]) → Future< void> -
Disk.copyToDiskfrom the default disk. -
delete(
Object paths) → Future< bool> -
Disk.deleteon the default disk. -
deleteDirectory(
String path) → Future< bool> -
Disk.deleteDirectoryon the default disk. -
directories(
[String directory = '']) → Future< List< String> > -
Disk.directorieson the default disk. -
directoryExists(
String path) → Future< bool> -
Disk.directoryExistson 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.downloadon the default disk. -
exists(
String path) → Future< bool> -
Disk.existson 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.fileson the default disk. -
get(
String path) → Future< String> -
Disk.geton the default disk. -
json<
T> (String path, {Map< Type, dynamic> ? modelDecoders}) → Future<T?> -
Disk.jsonon the default disk. -
lastModified(
String path) → Future< DateTime> -
Disk.lastModifiedon the default disk. -
list(
[String directory = '', bool recursive = false]) → Future< List< DiskEntry> > -
Disk.liston the default disk. -
makeDirectory(
String path) → Future< void> -
Disk.makeDirectoryon the default disk. -
mimeType(
String path) → Future< String?> -
Disk.mimeTypeon the default disk. -
missing(
String path) → Future< bool> -
Disk.missingon the default disk. -
move(
String from, String to) → Future< void> -
Disk.moveon the default disk. -
moveToDisk(
String target, String path, [String? to]) → Future< void> -
Disk.moveToDiskfrom the default disk. -
path(
String path) → Future< String> -
Disk.pathon the default disk. -
prepend(
String path, String text, {String separator = '\n'}) → Future< void> -
Disk.prependon the default disk. -
prune(
{required Duration olderThan}) → Future< int> -
Disk.pruneon the default disk. -
put(
String path, Object contents) → Future< void> -
Disk.puton the default disk. -
putFile(
String directory, Object file) → Future< String> -
Disk.putFileon the default disk. -
putFileAs(
String directory, Object file, String name) → Future< String> -
Disk.putFileAson the default disk. -
putJson(
String path, Object? value) → Future< void> -
Disk.putJsonon the default disk. -
readStream(
String path) → Stream< List< int> > -
Disk.readStreamon the default disk. -
reset(
) → void - Restores the default disks and drops every fake.
-
scope(
String directory) → Disk -
Disk.scopeon the default disk. -
size(
String path) → Future< int> -
Disk.sizeon the default disk. -
url(
String path) → Future< Uri> -
Disk.urlon the default disk. -
usage(
) → Future< int> -
Disk.usageon 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 asassetsstay real.