summaryrefslogtreecommitdiff
path: root/plugins/CloudFile/src/Services/yandex_api.h
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2017-05-07 02:25:29 +0300
committeraunsane <aunsane@gmail.com>2017-05-07 02:25:29 +0300
commitff6a107e5f566da2644fbfe36455467beafaeb1e (patch)
tree3d5b96794ee835c8686a74da6c418c440c91c403 /plugins/CloudFile/src/Services/yandex_api.h
parent453b3de91c372ee7b2661771aead6675e12fe98f (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/yandex_api.h')
-rw-r--r--plugins/CloudFile/src/Services/yandex_api.h24
1 files changed, 19 insertions, 5 deletions
diff --git a/plugins/CloudFile/src/Services/yandex_api.h b/plugins/CloudFile/src/Services/yandex_api.h
index 2a83abb634..56d77feb8c 100644
--- a/plugins/CloudFile/src/Services/yandex_api.h
+++ b/plugins/CloudFile/src/Services/yandex_api.h
@@ -52,27 +52,41 @@ namespace YandexAPI
class GetUploadUrlRequest : public HttpRequest
{
public:
- GetUploadUrlRequest(const char *token, const char *path) :
+ GetUploadUrlRequest(const char *token, const char *path, OnConflict strategy = NONE) :
HttpRequest(REQUEST_GET, YADISK_API "/upload")
{
AddOAuthHeader(token);
AddUrlParameter("path=%s", ptrA(mir_urlEncode(path)));
- AddUrlParameter("overwrite=true");
+ if (strategy == OnConflict::REPLACE)
+ AddUrlParameter("overwrite=true");
}
};
class UploadFileRequest : public HttpRequest
{
public:
- UploadFileRequest(const char *token, const char *url, const char *data, size_t size) :
+ UploadFileRequest(const char *url, const char *data, size_t size) :
HttpRequest(REQUEST_PUT, url)
{
- AddOAuthHeader(token);
-
SetData(data, size);
}
};
+ class UploadFileChunkRequest : public HttpRequest
+ {
+ public:
+ UploadFileChunkRequest(const char *url, const char *chunk, size_t chunkSize, uint64_t offset, uint64_t fileSize) :
+ HttpRequest(REQUEST_PUT, url)
+ {
+ uint64_t rangeMin = offset;
+ uint64_t rangeMax = offset + chunkSize - 1;
+ CMStringA range(CMStringDataFormat::FORMAT, "bytes %I64u-%I64u/%I64u", rangeMin, rangeMax, fileSize);
+ AddHeader("Content-Range", range);
+
+ SetData(chunk, chunkSize);
+ }
+ };
+
class CreateFolderRequest : public HttpRequest
{
public: