From 1d5087a3c2e68dbfb013b4e945f7e9308a13e0c6 Mon Sep 17 00:00:00 2001 From: cuihaikuo Date: Sat, 28 Apr 2018 14:23:16 +0800 Subject: [PATCH] Support uploading a folder by upload_api. --- server/upload-file.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/server/upload-file.c b/server/upload-file.c index 2619628..296a9af 100644 --- a/server/upload-file.c +++ b/server/upload-file.c @@ -519,6 +519,7 @@ upload_api_cb(evhtp_request_t *req, void *arg) int error_code = ERROR_INTERNAL; char *filenames_json, *tmp_files_json; int replace = 0; + int rc; if (evhtp_request_get_method(req) == htp_method_OPTIONS) { /* If CORS preflight header, then create an empty body response (200 OK) @@ -574,18 +575,28 @@ upload_api_cb(evhtp_request_t *req, void *arg) filenames_json = file_list_to_json (fsm->filenames); tmp_files_json = file_list_to_json (fsm->files); + char *abs_path = NULL; + rc = create_relative_path (fsm, parent_dir, &abs_path); + if (rc < 0) { + goto error; + } else if (abs_path) { + parent_dir = abs_path; + } + char *ret_json = NULL; char *task_id = NULL; - int rc = seaf_repo_manager_post_multi_files (seaf->repo_mgr, - fsm->repo_id, - parent_dir, - filenames_json, - tmp_files_json, - fsm->user, - replace, - &ret_json, - fsm->need_idx_progress ? &task_id : NULL, - &error); + rc = seaf_repo_manager_post_multi_files (seaf->repo_mgr, + fsm->repo_id, + parent_dir, + filenames_json, + tmp_files_json, + fsm->user, + replace, + &ret_json, + fsm->need_idx_progress ? &task_id : NULL, + &error); + if (abs_path) + g_free (abs_path); g_free (filenames_json); g_free (tmp_files_json); if (rc < 0) {