aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorAlexander Tkachev2016-05-30 13:46:14 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commita19fc52c329fdb0611eee7aedfb20fb0d1b9269c (patch)
tree9f99c46cca92d811d4ea5976188f05cfbc45e7e2 /backends
parentb9e3730ccd9a76101ef0cb8812f41c371a24d0d6 (diff)
downloadscummvm-rg350-a19fc52c329fdb0611eee7aedfb20fb0d1b9269c.tar.gz
scummvm-rg350-a19fc52c329fdb0611eee7aedfb20fb0d1b9269c.tar.bz2
scummvm-rg350-a19fc52c329fdb0611eee7aedfb20fb0d1b9269c.zip
CLOUD: Make DropboxUploadRequest use "/upload" too
If file could be uploaded in one API call, no need to create a session (which requires at least two calls: to start and then to finish it).
Diffstat (limited to 'backends')
-rw-r--r--backends/cloud/dropbox/dropboxstorage.cpp7
-rw-r--r--backends/cloud/dropbox/dropboxuploadrequest.cpp12
2 files changed, 14 insertions, 5 deletions
diff --git a/backends/cloud/dropbox/dropboxstorage.cpp b/backends/cloud/dropbox/dropboxstorage.cpp
index 1f983cec67..ab3f5d0874 100644
--- a/backends/cloud/dropbox/dropboxstorage.cpp
+++ b/backends/cloud/dropbox/dropboxstorage.cpp
@@ -105,6 +105,7 @@ void DropboxStorage::printBool(BoolResponse pair) {
}
void DropboxStorage::printUploadStatus(UploadResponse pair) {
+ debug(" ");
UploadStatus status = pair.value;
if (status.interrupted) {
debug("upload interrupted by user");
@@ -118,9 +119,9 @@ void DropboxStorage::printUploadStatus(UploadResponse pair) {
debug("upload HTTP response code = %ld", status.httpResponseCode);
if (!status.failed) {
debug("uploaded file info:");
- debug("path: %s", status.file.path().c_str());
- debug("size: %u", status.file.size());
- debug("timestamp: %u", status.file.timestamp());
+ debug("\tpath: %s", status.file.path().c_str());
+ debug("\tsize: %u", status.file.size());
+ debug("\ttimestamp: %u", status.file.timestamp());
}
}
diff --git a/backends/cloud/dropbox/dropboxuploadrequest.cpp b/backends/cloud/dropbox/dropboxuploadrequest.cpp
index 18e1173eef..e422793bc4 100644
--- a/backends/cloud/dropbox/dropboxuploadrequest.cpp
+++ b/backends/cloud/dropbox/dropboxuploadrequest.cpp
@@ -65,8 +65,16 @@ void DropboxUploadRequest::uploadNextPart() {
Common::JSONObject jsonRequestParameters;
if (_contentsStream->pos() == 0 || _sessionId == "") {
- url += "start";
- jsonRequestParameters.setVal("close", new Common::JSONValue(false));
+ if (_contentsStream->size() <= UPLOAD_PER_ONE_REQUEST) {
+ url = "https://content.dropboxapi.com/2/files/upload";
+ jsonRequestParameters.setVal("path", new Common::JSONValue(_savePath));
+ jsonRequestParameters.setVal("mode", new Common::JSONValue("overwrite"));
+ jsonRequestParameters.setVal("autorename", new Common::JSONValue(false));
+ jsonRequestParameters.setVal("mute", new Common::JSONValue(false));
+ } else {
+ url += "start";
+ jsonRequestParameters.setVal("close", new Common::JSONValue(false));
+ }
} else {
if (_contentsStream->size() - _contentsStream->pos() <= UPLOAD_PER_ONE_REQUEST) {
url += "finish";