Skip to content

Commit

Permalink
fix: GoogleDriveService.uploadFile function should be able to update …
Browse files Browse the repository at this point in the history
…an existing file
  • Loading branch information
timobaehr committed Mar 4, 2024
1 parent 73b2dc1 commit ee2fae6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 0.0.7
## 0.0.8

* Updating Drive files should work with GoogleDriveService.uploadFile function
* GoogleDriveService is making it easier to get the file content
* GoogleDriveFile meta data can contain a description
* Fix: GoogleDriveFile should return file.id (otherwise there is to reference to the cloud file)
Expand Down
19 changes: 15 additions & 4 deletions lib/fl_cloud_storage/vendor/google_drive/google_drive_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,22 @@ class GoogleDriveService implements ICloudService<GoogleDriveFile, GoogleDriveFo
file.file.parents = [...?file.file.parents, parent.folder.id!];
}
}
final uploadedFile = await _driveApi!.files.create(file.file, uploadMedia: file.media);
if (file.fileId != null) {
final v3.File driveFile = v3.File()
..description = file.description
..name = file.fileName;
final updatedFile = await _driveApi!.files.update(driveFile, file.fileId!, uploadMedia: file.media);
return file.copyWith(
fileId: updatedFile.id,
fileName: updatedFile.name,
parents: updatedFile.parents,
);
}
final cratedFile = await _driveApi!.files.create(file.file, uploadMedia: file.media);
return file.copyWith(
fileId: uploadedFile.id,
fileName: uploadedFile.name,
parents: uploadedFile.parents,
fileId: cratedFile.id,
fileName: cratedFile.name,
parents: cratedFile.parents,
);
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: fl_cloud_storage
description: Store files in the cloud from Flutter apps
version: 0.0.7
version: 0.0.8
homepage: https://github.com/ehwplus/fl_cloud_storage

environment:
Expand Down

0 comments on commit ee2fae6

Please sign in to comment.