getFileStorageReferenceByName method

Future<FileStorageReference?> getFileStorageReferenceByName(
  1. String name, {
  2. String? studyId,
})

Get a FileStorageReference that reference a file with the original name name for study with id studyId.

studyId can be omitted if specified as part of this service's study.

If more than one file with the same name exists, the first one is returned. If no files with that name exists, null is returned.

Implementation

Future<FileStorageReference?> getFileStorageReferenceByName(
  String name, {
  String? studyId,
}) async {
  final List<CarpFileResponse> files = await queryFiles(
    'original_name==$name',
    studyId: getStudyId(studyId),
  );

  return (files.isNotEmpty)
      ? FileStorageReference._(this, getStudyId(studyId), files[0].id)
      : null;
}