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).
This commit is contained in:
Alexander Tkachev 2016-05-30 13:46:14 +06:00
parent b9e3730ccd
commit a19fc52c32
2 changed files with 14 additions and 5 deletions

View file

@ -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";