mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
refactor: File upload (#5542)
* 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
This commit is contained in:
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user