speed up file uploads

This commit is contained in:
Sai Naw Wun
2020-11-13 03:09:53 +06:30
parent ca21f48dab
commit 96330a80dc
2 changed files with 23 additions and 12 deletions

View File

@@ -255,11 +255,11 @@ class PackageModel extends BaseModel {
if (files.length > uploadPhotoLimit)
throw Exception("Exceed number of file upload");
package.photoUrls = package.photoUrls == null ? [] : package.photoUrls;
for (File f in files) {
String path = Path.join(pkg_files_path);
String url = await uploadStorage(path, f);
String path = Path.join(pkg_files_path);
List<String> urls = await uploadFiles(path, files);
urls.forEach((url) {
package.photoUrls.add(url);
}
});
}
return Services.instance.packageService.createReceiving(package);
}
@@ -284,11 +284,11 @@ class PackageModel extends BaseModel {
if (count > uploadPhotoLimit)
throw Exception("Exceed number of file upload");
package.photoUrls = package.photoUrls == null ? [] : package.photoUrls;
for (File f in files) {
String path = Path.join(pkg_files_path);
String url = await uploadStorage(path, f);
String path = Path.join(pkg_files_path);
List<String> urls = await uploadFiles(path, files);
urls.forEach((url) {
package.photoUrls.add(url);
}
});
}
await Services.instance.packageService.updateReceiving(package);
}
@@ -314,11 +314,11 @@ class PackageModel extends BaseModel {
if (count > uploadPhotoLimit)
throw Exception("Exceed number of file upload");
package.photoUrls = package.photoUrls == null ? [] : package.photoUrls;
for (File f in files) {
String path = Path.join(pkg_files_path);
String url = await uploadStorage(path, f);
String path = Path.join(pkg_files_path);
List<String> urls = await uploadFiles(path, files);
urls.forEach((url) {
package.photoUrls.add(url);
}
});
package.photoUrls.removeWhere((e) => deletedUrls.contains(e));
}
await Services.instance.packageService.updateProcessing(package);