storeFile method

Future<void> storeFile({
  1. required String storageId,
  2. required String path,
  3. required ByteData byteData,
  4. DateTime? expiration,
})

Store a file in the cloud storage. storageId is typically 'public' or 'private'. The public storage can be accessed through a public URL. The file is stored at the path relative to the cloud storage root directory, if a file already exists it will be replaced.

Implementation

Future<void> storeFile({
  required String storageId,
  required String path,
  required ByteData byteData,
  DateTime? expiration,
}) async {
  var storage = _session.server.serverpod.storage[storageId];
  if (storage == null) {
    throw CloudStorageException('Storage $storageId is not registered');
  }

  await storage.storeFile(session: _session, path: path, byteData: byteData);
}