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:
parent
b9e3730ccd
commit
a19fc52c32
2 changed files with 14 additions and 5 deletions
|
@ -105,6 +105,7 @@ void DropboxStorage::printBool(BoolResponse pair) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DropboxStorage::printUploadStatus(UploadResponse pair) {
|
void DropboxStorage::printUploadStatus(UploadResponse pair) {
|
||||||
|
debug(" ");
|
||||||
UploadStatus status = pair.value;
|
UploadStatus status = pair.value;
|
||||||
if (status.interrupted) {
|
if (status.interrupted) {
|
||||||
debug("upload interrupted by user");
|
debug("upload interrupted by user");
|
||||||
|
@ -118,9 +119,9 @@ void DropboxStorage::printUploadStatus(UploadResponse pair) {
|
||||||
debug("upload HTTP response code = %ld", status.httpResponseCode);
|
debug("upload HTTP response code = %ld", status.httpResponseCode);
|
||||||
if (!status.failed) {
|
if (!status.failed) {
|
||||||
debug("uploaded file info:");
|
debug("uploaded file info:");
|
||||||
debug("path: %s", status.file.path().c_str());
|
debug("\tpath: %s", status.file.path().c_str());
|
||||||
debug("size: %u", status.file.size());
|
debug("\tsize: %u", status.file.size());
|
||||||
debug("timestamp: %u", status.file.timestamp());
|
debug("\ttimestamp: %u", status.file.timestamp());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,8 +65,16 @@ void DropboxUploadRequest::uploadNextPart() {
|
||||||
Common::JSONObject jsonRequestParameters;
|
Common::JSONObject jsonRequestParameters;
|
||||||
|
|
||||||
if (_contentsStream->pos() == 0 || _sessionId == "") {
|
if (_contentsStream->pos() == 0 || _sessionId == "") {
|
||||||
url += "start";
|
if (_contentsStream->size() <= UPLOAD_PER_ONE_REQUEST) {
|
||||||
jsonRequestParameters.setVal("close", new Common::JSONValue(false));
|
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 {
|
} else {
|
||||||
if (_contentsStream->size() - _contentsStream->pos() <= UPLOAD_PER_ONE_REQUEST) {
|
if (_contentsStream->size() - _contentsStream->pos() <= UPLOAD_PER_ONE_REQUEST) {
|
||||||
url += "finish";
|
url += "finish";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue