Fix issues with respect to uploading photos
This commit is contained in:
parent
5c293fe827
commit
2cdb268b80
3 changed files with 11 additions and 4 deletions
|
@ -20,6 +20,9 @@ class Configuration {
|
|||
}
|
||||
|
||||
String getHttpEndpoint() {
|
||||
if (getEndpoint() == null) {
|
||||
return "";
|
||||
}
|
||||
return "http://" + getEndpoint() + ":8080";
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ class Photo {
|
|||
Photo.fromJson(Map<String, dynamic> json)
|
||||
: uploadedFileId = json["fileId"],
|
||||
remotePath = json["path"],
|
||||
title = json["title"],
|
||||
createTimestamp = json["createTimestamp"],
|
||||
syncTimestamp = json["syncTimestamp"];
|
||||
|
||||
|
|
|
@ -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<Photo> _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(),
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue