1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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_
|