getFileMetadata method

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

Retrieves metadata for the file or directory at the specified path.

Implementation

@override
Future<CloudFile> getFileMetadata(String path) {
  return _executeRequest(() async {
    final file = await _getFileByPath(path);
    if (file == null) {
      throw Exception('GoogleDriveProvider: File not found at $path');
    }
    // Convert the Google Drive file object to a generic CloudFile.
    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
      },
    );
  });
}