Queued upload

This commit is contained in:
2024-08-01 22:13:08 +08:00
parent adb415700a
commit 8b3c45ab29
10 changed files with 706 additions and 312 deletions

View File

@@ -38,11 +38,8 @@ class AttachmentProvider extends GetConnect {
}
Future<Response> createAttachment(
Uint8List data,
String path,
String usage,
Map<String, dynamic>? metadata,
) async {
Uint8List data, String path, String usage, Map<String, dynamic>? metadata,
{Function(double)? onProgress}) async {
final AuthProvider auth = Get.find();
if (auth.isAuthorized.isFalse) throw Exception('unauthorized');
@@ -71,7 +68,13 @@ class AttachmentProvider extends GetConnect {
if (mimetypeOverride != null) 'mimetype': mimetypeOverride,
'metadata': jsonEncode(metadata),
});
final resp = await client.post('/attachments', payload);
final resp = await client.post(
'/attachments',
payload,
uploadProgress: (progress) {
if (onProgress != null) onProgress(progress);
},
);
if (resp.statusCode != 200) {
throw Exception(resp.bodyString);
}