From d06ffc219c0c25c562a3df72f12645fc5b5800c2 Mon Sep 17 00:00:00 2001 From: Maxime Daniel Date: Tue, 17 Oct 2023 19:13:02 +0200 Subject: [PATCH] zflist: hub: add custom filename on upload --- zflist/actions_hub.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/zflist/actions_hub.c b/zflist/actions_hub.c index 946d1b1..fbe097b 100644 --- a/zflist/actions_hub.c +++ b/zflist/actions_hub.c @@ -127,12 +127,19 @@ static http_t zf_hub_curl(zf_callback_t *cb, char *url, char *payload, char *met method = "POST"; curl_mime *form = curl_mime_init(curl.handler); - curl_mimepart *field = field = curl_mime_addpart(form); + curl_mimepart *field = curl_mime_addpart(form); curl_mime_name(field, "file"); curl_mime_filedata(field, payload); curl_easy_setopt(curl.handler, CURLOPT_MIMEPOST, form); + + char tmpname[1024]; + struct curl_slist *headers = NULL; + sprintf(tmpname, "X-Original-Name: %s", payload); + headers = curl_slist_append(headers, tmpname); + + curl_easy_setopt(curl.handler, CURLOPT_HTTPHEADER, headers); } if(payload && strcmp(method, "JSON") == 0) { @@ -142,9 +149,9 @@ static http_t zf_hub_curl(zf_callback_t *cb, char *url, char *payload, char *met curl_easy_setopt(curl.handler, CURLOPT_POSTFIELDS, payload); struct curl_slist *headers = NULL; - curl_slist_append(headers, "Accept: application/json"); - curl_slist_append(headers, "Content-Type: application/json"); - curl_slist_append(headers, "Charset: utf-8"); + headers = curl_slist_append(headers, "Accept: application/json"); + headers = curl_slist_append(headers, "Content-Type: application/json"); + headers = curl_slist_append(headers, "Charset: utf-8"); curl_easy_setopt(curl.handler, CURLOPT_HTTPHEADER, headers); }