getFileData method

Future<Uint8List> getFileData(
  1. String gcsPath
)

Implementation

Future<Uint8List> getFileData(String gcsPath) async {
  try {
    final fileRef = _storage.refFromURL(gcsPath);
    final res = await fileRef.getData();

    if (res != null) {
      return res;
    }
    _log.logCustom(
        StorageServiceLog('getFileData', 'File $gcsPath was not found'));

    throw StorageServiceException(
      message: 'File $gcsPath was not found',
      code: RdevCode.NotFound,
    );
  } catch (err) {
    _log.logCustom(StorageServiceLog('getFileData', err, StackTrace.current));
    if (err is StorageServiceException) {
      rethrow;
    }
    throw StorageServiceException(
      message: err.toString(),
    );
  }
}