Skip to content

Commit

Permalink
refactor: File upload (AppFlowy-IO#5542)
Browse files Browse the repository at this point in the history
* chore: rename service

* refactor: upload

* chore: save upload meta data

* chore: add sql test

* chore: uploader

* chore: fix upload

* chore: cache file and remove after finish

* chore: retry upload

* chore: pause when netowork unreachable

* chore: add event test

* chore: add test

* chore: clippy

* chore: update client-api commit id

* chore: fix flutter test
  • Loading branch information
appflowy authored Jun 19, 2024
1 parent fdaca36 commit b64da2c
Show file tree
Hide file tree
Showing 61 changed files with 2,687 additions and 643 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ class DocumentService {
/// Upload a file to the cloud storage.
Future<FlowyResult<UploadedFilePB, FlowyError>> uploadFile({
required String localFilePath,
bool isAsync = true,
required String documentId,
}) async {
final workspace = await FolderEventReadCurrentWorkspace().send();
return workspace.fold((l) async {
final payload = UploadFileParamsPB(
workspaceId: l.id,
localFilePath: localFilePath,
isAsync: isAsync,
documentId: documentId,
);
final result = await DocumentEventUploadFile(payload).send();
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ extension PasteFromImage on EditorState {
await File(copyToPath).writeAsBytes(imageBytes);
final String? path;

if (context.mounted) {
showSnackBarMessage(
context,
LocaleKeys.document_imageBlock_imageIsUploading.tr(),
);
}

if (isLocalMode) {
path = await saveImageToLocalStorage(copyToPath);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ Future<(String? path, String? errorMessage)> saveImageToCloudStorage(
);
}
final documentService = DocumentService();
Log.debug("Uploading image local path: $localImagePath");
final result = await documentService.uploadFile(
localFilePath: localImagePath,
isAsync: false,
// TODO(lucas): replace with actual documentId
documentId: "temp",
);
return result.fold(
(s) async {
Expand Down
68 changes: 51 additions & 17 deletions frontend/appflowy_tauri/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/appflowy_tauri/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ collab-user = { version = "0.2" }
# Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "430e3e15c9a1dc6aba2a9599d17d946a61ac7cae" }
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "6262816043efeede8823d7a7ea252083adf407e9" }

[dependencies]
serde_json.workspace = true
Expand Down
Loading

0 comments on commit b64da2c

Please sign in to comment.