Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/targets/shell/curl/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,16 @@ export const curl: Client<CurlOptions> = {
case 'multipart/form-data':
postData.params?.forEach(param => {
let post = '';
// If the parameter is a filename, we want to put shell quotes around
// it rather than URL quoting it. Curl wants `file='@img copy.jpg'`
// not `file=@img%20copy.jpg`, which it will fail to find
if (param.fileName) {
post = `${param.name}=@${param.fileName}`;
post = `${param.name}='@${param.fileName}'`;
} else {
post = `${param.name}=${param.value}`;
post = quote(`${param.name}=${param.value}`);
}

push(`${arg('form')} ${quote(post)}`);
push(`${arg('form')} ${post}`);
});
break;

Expand Down
2 changes: 1 addition & 1 deletion src/targets/shell/curl/fixtures/multipart-data.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
curl --request POST \
--url https://httpbin.org/anything \
--header 'content-type: multipart/form-data' \
--form foo=@src/fixtures/files/hello.txt \
--form foo='@src/fixtures/files/hello.txt' \
--form 'bar=Bonjour le monde'
2 changes: 1 addition & 1 deletion src/targets/shell/curl/fixtures/multipart-file.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
curl --request POST \
--url https://httpbin.org/anything \
--header 'content-type: multipart/form-data' \
--form foo=@src/fixtures/files/hello.txt
--form foo='@src/fixtures/files/hello.txt'