summaryrefslogtreecommitdiff
path: root/plugins/Dropbox/src/api/upload.h
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-05-13 14:29:47 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-05-13 14:29:47 +0000
commit71846c4e387e27164ffde6b2e8a188b3bc21b2eb (patch)
tree0651eb829e128942cb0fe361862f93436fdb7a23 /plugins/Dropbox/src/api/upload.h
parentf112b278674402d2ea5428307f84de193695a07c (diff)
Dropbox: refactoring of http requests
git-svn-id: http://svn.miranda-ng.org/main/trunk@13570 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dropbox/src/api/upload.h')
-rw-r--r--plugins/Dropbox/src/api/upload.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/plugins/Dropbox/src/api/upload.h b/plugins/Dropbox/src/api/upload.h
new file mode 100644
index 0000000000..323bf907a5
--- /dev/null
+++ b/plugins/Dropbox/src/api/upload.h
@@ -0,0 +1,47 @@
+#ifndef _DROPBOX_API_UPLOAD_H_
+#define _DROPBOX_API_UPLOAD_H_
+
+class UploadFileRequest : public HttpRequest
+{
+public:
+ UploadFileRequest(const char *token, const char *fileName, const char *data, int length) :
+ HttpRequest(REQUEST_PUT, FORMAT, DROPBOX_APICONTENT_URL "/files_put/auto/%s", fileName)
+ {
+ AddBearerAuthHeader(token);
+ pData = (char*)data;
+ dataLength = length;
+ }
+};
+
+class UploadFileChunkRequest : public HttpRequest
+{
+public:
+ UploadFileChunkRequest(const char *token, const char *data, int length) :
+ HttpRequest(REQUEST_PUT, DROPBOX_APICONTENT_URL "/chunked_upload")
+ {
+ AddBearerAuthHeader(token);
+ AddHeader("Content-Type", "application/octet-stream");
+ pData = (char*)data;
+ dataLength = length;
+ }
+
+ UploadFileChunkRequest(const char *token, const char *uploadId, size_t offset, const char *data, int length) :
+ HttpRequest(REQUEST_PUT, FORMAT, DROPBOX_APICONTENT_URL "/chunked_upload?upload_id=%s&offset=%i", uploadId, offset)
+ {
+ AddBearerAuthHeader(token);
+ AddHeader("Content-Type", "application/octet-stream");
+ pData = (char*)data;
+ dataLength = length;
+ }
+
+ UploadFileChunkRequest(const char *token, const char *uploadId, const char *path) :
+ HttpRequest(REQUEST_POST, FORMAT, DROPBOX_APICONTENT_URL "/commit_chunked_upload/auto/%s", path)
+ {
+ AddBearerAuthHeader(token);
+ AddHeader("Content-Type", "application/x-www-form-urlencoded");
+
+ AddUrlParameter("upload_id=%s", uploadId);
+ }
+};
+
+#endif //_DROPBOX_API_UPLOAD_H_