diff --git a/lib/core/configuration.dart b/lib/core/configuration.dart index 0925183ca7f568e88572144a28dce0e31a92a93b..7bda1e0520bc67dc1fc6ab6dc698c3ee225d022b 100644 --- a/lib/core/configuration.dart +++ b/lib/core/configuration.dart @@ -20,6 +20,9 @@ class Configuration { } String getHttpEndpoint() { + if (getEndpoint() == null) { + return ""; + } return "http://" + getEndpoint() + ":8080"; } diff --git a/lib/models/photo.dart b/lib/models/photo.dart index 75662eb3c6b7b1486dad3cc7d9d0d5354dfd0181..d779ebb8efc15a446f5f118f8ee0b45eb09570a9 100644 --- a/lib/models/photo.dart +++ b/lib/models/photo.dart @@ -18,6 +18,7 @@ class Photo { Photo.fromJson(Map json) : uploadedFileId = json["fileId"], remotePath = json["path"], + title = json["title"], createTimestamp = json["createTimestamp"], syncTimestamp = json["syncTimestamp"]; diff --git a/lib/photo_sync_manager.dart b/lib/photo_sync_manager.dart index a564fd2ba0b0e7bf4d17acd5dfbc86a22d55f298..d89aac74c8a49b2f7eb99ecf69a7f511773a9a25 100644 --- a/lib/photo_sync_manager.dart +++ b/lib/photo_sync_manager.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'dart:io'; import 'package:logger/logger.dart'; -import 'package:http_parser/http_parser.dart'; import 'package:myapp/core/event_bus.dart'; import 'package:myapp/db/db_helper.dart'; import 'package:myapp/events/user_authenticated_event.dart'; @@ -79,6 +78,9 @@ class PhotoSyncManager { first.createTimestamp.compareTo(second.createTimestamp)); _updateDatabase(photos, prefs, lastDBUpdateTimestamp).then((_) { _isSyncInProgress = false; + _syncPhotos().then((_) { + _deletePhotos(); + }); }); } } @@ -168,9 +170,10 @@ class PhotoSyncManager { Future _uploadFile(Photo localPhoto) async { var formData = FormData.fromMap({ - "file": - MultipartFile.fromFile((await localPhoto.getAsset().originFile).path), - "filename": localPhoto.title, + "file": MultipartFile.fromBytes((await localPhoto.getOriginalBytes()), + filename: localPhoto.title), + "title": localPhoto.title, + "createTimestamp": localPhoto.createTimestamp, "user": Configuration.instance.getUsername(), "token": Configuration.instance.getToken(), });