Skip to content

Commit

Permalink
[libcurl] support uploading large files
Browse files Browse the repository at this point in the history
curl_mime_data requires storing the file in memory
use curl_mime_filename instead of curl_mime_data to support uploading large files.
  • Loading branch information
myml committed Sep 11, 2024
1 parent b7f31dd commit a2790bf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,16 @@ void apiClient_invoke(apiClient_t *apiClient,
memcpy(&fileVar,
keyValuePair->value,
sizeof(fileVar));
curl_mime_data(part,
fileVar->data,
fileVar->len);
curl_mime_filename(part,
"image.png");
if (fileVar->filepath) {
curl_mime_filedata(part, fileVar->filepath);
} else {
curl_mime_data(part, fileVar->data, fileVar->len);
}
if (fileVar->filename) {
curl_mime_filename(part, fileVar->filename);
} else {
curl_mime_filename(part, "image.png");
}
} else {
curl_mime_data(part,
keyValuePair->value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ typedef struct binary_t
{
uint8_t* data;
unsigned int len;
char *filename;
char *filepath;
} binary_t;

binary_t* instantiate_binary_t(char* data, int len);
Expand Down

0 comments on commit a2790bf

Please sign in to comment.