getFileRef method

String? getFileRef(
  1. String entityPath
)

Implementation

String? getFileRef(String entityPath) {
  entityPath = entityPath.replaceAll('\\', '/');
  if (!_containFile(entityPath)) return null;

  String bucketPath = folderPath;
  // file path: /path/to/bucket/bucket_name/sub/dir/file.ext
  // bucket path: /path/to/bucket/bucket_name
  // desired output : sub/dir/file.ext
  var parts = entityPath.split(bucketPath);
  if (parts.isEmpty) {
    return null;
  }
  return parts.last.strip('/');
}