diff options
author | aunsane <aunsane@gmail.com> | 2017-05-07 02:25:29 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2017-05-07 02:25:29 +0300 |
commit | ff6a107e5f566da2644fbfe36455467beafaeb1e (patch) | |
tree | 3d5b96794ee835c8686a74da6c418c440c91c403 /plugins/CloudFile/src/Services/google_api.h | |
parent | 453b3de91c372ee7b2661771aead6675e12fe98f (diff) |
CloudFile:
- reworked options to dupport default service
- added options to select conflict behavior
- multiple fix and refactoring
- version bump
Diffstat (limited to 'plugins/CloudFile/src/Services/google_api.h')
-rw-r--r-- | plugins/CloudFile/src/Services/google_api.h | 10 |
1 files changed, 8 insertions, 2 deletions
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()); |