Skip to content

Commit

Permalink
zflist: hub: add custom filename on upload
Browse files Browse the repository at this point in the history
  • Loading branch information
maxux committed Oct 17, 2023
1 parent 974a12b commit d06ffc2
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions zflist/actions_hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
Expand Down

0 comments on commit d06ffc2

Please sign in to comment.