diff options
author | aunsane <aunsane@gmail.com> | 2017-04-27 01:53:37 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2017-04-27 01:54:12 +0300 |
commit | 7b1d58962694bd6dd1971d6eda673ddc0877f7c2 (patch) | |
tree | ab0e4abefcdfbec12bf4fe7de1b5386cf1ac9378 /plugins/CloudFile/src/Services/microsoft_api.h | |
parent | f27fbe387bede98cf64d7fd7fb3dcff1ba60279d (diff) |
CloudFile: fix uploading small files for GDrive and OneDrive
Diffstat (limited to 'plugins/CloudFile/src/Services/microsoft_api.h')
-rw-r--r-- | plugins/CloudFile/src/Services/microsoft_api.h | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/plugins/CloudFile/src/Services/microsoft_api.h b/plugins/CloudFile/src/Services/microsoft_api.h index 1c3c323520..395d6e434d 100644 --- a/plugins/CloudFile/src/Services/microsoft_api.h +++ b/plugins/CloudFile/src/Services/microsoft_api.h @@ -37,21 +37,35 @@ namespace OneDriveAPI } }; - /*class RevokeAccessTokenRequest : public HttpRequest + class UploadFileRequest : public HttpRequest { public: - RevokeAccessTokenRequest(const char *token) : - HttpRequest(REQUEST_POST, MS_OAUTH "/logout") + UploadFileRequest(const char *token, const char *name, const char *data, size_t size) : + HttpRequest(REQUEST_PUT, FORMAT, ONEDRIVE_API "/special/approot:/%s:/content", ptrA(mir_urlEncode(name))) { - AddUrlParameter("token=%s", token); + AddUrlParameter("@microsoft.graph.conflictBehavior=rename"); + + AddBearerAuthHeader(token); + + SetData(data, size); + } + + UploadFileRequest(const char *token, const char *parentId, const char *name, const char *data, size_t size) : + HttpRequest(REQUEST_PUT, FORMAT, ONEDRIVE_API "/items/{parent-id}:/{filename}:/content", parentId, ptrA(mir_urlEncode(name))) + { + AddUrlParameter("@microsoft.graph.conflictBehavior=rename"); + + AddBearerAuthHeader(token); + + SetData(data, size); } - };*/ + }; class CreateUploadSessionRequest : public HttpRequest { public: CreateUploadSessionRequest(const char *token, const char *name) : - HttpRequest(REQUEST_POST, FORMAT, ONEDRIVE_API "/special/approot:/%s:/createUploadSession", name) + HttpRequest(REQUEST_POST, FORMAT, ONEDRIVE_API "/special/approot:/%s:/createUploadSession", ptrA(mir_urlEncode(name))) { AddBearerAuthHeader(token); AddHeader("Content-Type", "application/json"); @@ -59,8 +73,7 @@ namespace OneDriveAPI JSONNode item(JSON_NODE); item.set_name("item"); item - << JSONNode("@microsoft.graph.conflictBehavior", "rename") - << JSONNode("name", name); + << JSONNode("@microsoft.graph.conflictBehavior", "rename"); JSONNode params(JSON_NODE); params << item; |