getFileMetadata method

  1. @override
Future<CloudFile> getFileMetadata(
  1. String path
)
override

Gets the metadata of a file.

Implementation

@override
Future<CloudFile> getFileMetadata(String path) async {
  _checkAuth();

  final file = await _getFileByPath(path);
  if (file == null) {
    throw Exception('GoogleDriveProvider: File not found at $path');
  }

  return CloudFile(
    path: path,
    name: file.name ?? 'Unnamed',
    size: file.size == null ? null : int.tryParse(file.size!),
    modifiedTime: file.modifiedTime ?? DateTime.now(),
    isDirectory: file.mimeType == 'application/vnd.google-apps.folder',
    metadata: {
      'id': file.id,
      'mimeType': file.mimeType,
      'parents': file.parents,
    },
  );
}