From ff6a107e5f566da2644fbfe36455467beafaeb1e Mon Sep 17 00:00:00 2001 From: aunsane Date: Sun, 7 May 2017 02:25:29 +0300 Subject: CloudFile: - reworked options to dupport default service - added options to select conflict behavior - multiple fix and refactoring - version bump --- plugins/CloudFile/src/Services/google_api.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'plugins/CloudFile/src/Services/google_api.h') diff --git a/plugins/CloudFile/src/Services/google_api.h b/plugins/CloudFile/src/Services/google_api.h index b609507caa..c73124cdad 100644 --- a/plugins/CloudFile/src/Services/google_api.h +++ b/plugins/CloudFile/src/Services/google_api.h @@ -54,7 +54,7 @@ namespace GDriveAPI class UploadFileRequest : public HttpRequest { public: - UploadFileRequest(const char *token, const char *name, const char *data, size_t size) : + UploadFileRequest(const char *token, const char *parentId, const char *name, const char *data, size_t size) : HttpRequest(REQUEST_POST, GDRIVE_UPLOAD) { AddBearerAuthHeader(token); @@ -67,6 +67,8 @@ namespace GDriveAPI body.AppendChar(0x0A); body.Append("{"); body.AppendFormat("\"name\": \"%s\"", name); + if (parentId) + body.AppendFormat("\"parents\": [\"%s\"]", parentId); body.Append("}"); body.AppendChar(0x0A); body.AppendChar(0x0A); @@ -86,7 +88,7 @@ namespace GDriveAPI class CreateUploadSessionRequest : public HttpRequest { public: - CreateUploadSessionRequest(const char *token, const char *name) : + CreateUploadSessionRequest(const char *token, const char *parentId, const char *name) : HttpRequest(REQUEST_POST, GDRIVE_UPLOAD) { AddUrlParameter("uploadType=resumable"); @@ -94,8 +96,12 @@ namespace GDriveAPI AddBearerAuthHeader(token); AddHeader("Content-Type", "application/json"); + JSONNode parents(JSON_ARRAY); + parents << JSONNode("", parentId); + JSONNode params(JSON_NODE); params << JSONNode("name", name); + params << parents; json_string data = params.write(); SetData(data.c_str(), data.length()); -- cgit v1.2.3