summaryrefslogtreecommitdiff
path: root/plugins/Dropbox/src/dropbox_transfers.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Dropbox/src/dropbox_transfers.cpp')
-rw-r--r--plugins/Dropbox/src/dropbox_transfers.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/plugins/Dropbox/src/dropbox_transfers.cpp b/plugins/Dropbox/src/dropbox_transfers.cpp
index 6473a0bcc6..801f2e344e 100644
--- a/plugins/Dropbox/src/dropbox_transfers.cpp
+++ b/plugins/Dropbox/src/dropbox_transfers.cpp
@@ -60,6 +60,19 @@ char* CDropbox::FinishUploadSession(const char *data, size_t size, const char *s
return path;
}
+void CDropbox::CreateFolder(const char *path)
+{
+ ptrA token(db_get_sa(NULL, MODULE, "TokenSecret"));
+ CreateFolderRequest request(token, path);
+ NLHR_PTR response(request.Send(hNetlibConnection));
+
+ // forder exists on server
+ if (response->resultCode == HTTP_STATUS_FORBIDDEN)
+ return;
+
+ HandleJsonResponseError(response);
+}
+
void CDropbox::CreateDownloadUrl(const char *path, char *url)
{
ptrA token(db_get_sa(NULL, MODULE, "TokenSecret"));
@@ -83,6 +96,15 @@ UINT CDropbox::UploadToDropbox(void *owner, void *arg)
FileTransferParam *ftp = (FileTransferParam*)arg;
try {
+ const TCHAR *folderName = ftp->GetFolderName();
+ if (folderName) {
+ char path[MAX_PATH], url[MAX_PATH];
+ PreparePath(folderName, path);
+ instance->CreateFolder(path);
+ instance->CreateDownloadUrl(path, url);
+ ftp->AppendFormatData(_T("%s\r\n"), ptrT(mir_utf8decodeT(url)));
+ }
+
ftp->FirstFile();
do
{