feat(mobile) reused HTTP client for uploading assets (#1487)

* feat(mobile) reused HTTP client for uploading assets

* remove unused comments
This commit is contained in:
Alex 2023-01-30 16:00:03 -06:00 committed by GitHub
parent aa68d35f42
commit 830fec0c29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,6 +29,7 @@ final backupServiceProvider = Provider(
); );
class BackupService { class BackupService {
final httpClient = http.Client();
final ApiService _apiService; final ApiService _apiService;
BackupService(this._apiService); BackupService(this._apiService);
@ -282,7 +283,8 @@ class BackupService {
), ),
); );
var response = await req.send(cancellationToken: cancelToken); var response =
await httpClient.send(req, cancellationToken: cancelToken);
if (response.statusCode == 200) { if (response.statusCode == 200) {
// asset is a duplicate (already exists on the server) // asset is a duplicate (already exists on the server)
@ -334,7 +336,6 @@ class BackupService {
Future<MultipartFile?> _getLivePhotoFile(AssetEntity entity) async { Future<MultipartFile?> _getLivePhotoFile(AssetEntity entity) async {
var motionFilePath = await entity.getMediaUrl(); var motionFilePath = await entity.getMediaUrl();
// var motionFilePath = '/var/mobile/Media/DCIM/103APPLE/IMG_3371.MOV'
if (motionFilePath != null) { if (motionFilePath != null) {
var validPath = motionFilePath.replaceAll('file://', ''); var validPath = motionFilePath.replaceAll('file://', '');