DatabaseCloudStorage class

The DatabaseCloudStorage uses the standard Serverpod database to store binary files. It's the default CloudStorage interface of Serverpod, but you may want to replace it with a more robust service depending on your needs, especially in your production environment.

Inheritance

Constructors

DatabaseCloudStorage(String storageId)
Creates a new DatabaseCloudStorage.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
storageId String
Identifies the storage. You can used multiple types cloud storages in a single Serverpod.
getter/setter pairinherited

Methods

createDirectFileUploadDescription({required Session session, required String path, Duration expirationDuration = const Duration(minutes: 10)}) Future<String?>
Creates an URL that a client can post a file to via http post, optionally within the specified duration. After the file has been sent, the verifyDirectFileUpload method should be called. If the file upload hasn't been confirmed before the URL expires, the file will be deleted.
override
deleteFile({required Session session, required String path}) Future<void>
Deletes the specified file if it exists. Does nothing if the file doesn't exist.
override
fileExists({required Session session, required String path}) Future<bool>
Returns true if the file exists.
override
getPublicUrl({required Session session, required String path}) Future<Uri?>
Returns a public link to a file in the storage. If the file isn't public or if no such file exists, null is returned.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
retrieveFile({required Session session, required String path}) Future<ByteData?>
Retrieves a file from the cloud storage or null if no such file exists. If the files are public, the may also be accessible through a web interface.
override
storeFile({required Session session, required String path, required ByteData byteData, DateTime? expiration, bool verified = true}) Future<void>
Saves a file to the cloud, optionally with an expiration time. The path should be relative to the root directory of the storage (i.e. the string shouldn't start with a slash). This method should throw an IOException if the file upload fails.
override
toString() String
A string representation of this object.
inherited
verifyDirectFileUpload({required Session session, required String path}) Future<bool>
Call this method once a direct file upload is completed. Failure to call this method will cause the uploaded file to be deleted.
override

Operators

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