curlconverter icon indicating copy to clipboard operation
curlconverter copied to clipboard

fix: Multiple Files with the Same Key in JSON output

Open RamDurgaSai opened this issue 1 year ago • 0 comments

Issue

When converting a curl command that uploads multiple files using the same form field name, the JSON output incorrectly overwrote values for keys appearing more than once. As a result, only the last file upload was represented in the files object.

Original curl Command:

curl -F [email protected] -F [email protected] -F "story=<hugefile.txt" --form-string "name=content" example.com/upload.cgi

Incorrect JSON Output (Before Fix):

{
    "url": "http://example.com/upload.cgi",
    "raw_url": "http://example.com/upload.cgi",
    "method": "post",
    "files": {
        "files": "picture2.jpg",
        "story": "hugefile.txt"
    }
}

Corrected JSON Output (After Fix): With the fix applied, the JSON output for multiple file uploads under the same key correctly maintains all entries:

{
    "url": "http://example.com/upload.cgi",
    "method": "post",
    "files": {
        "files": ["picture1.jpg", "picture2.jpg"],
        "story": "hugefile.txt"
    }
}

Closes #696

RamDurgaSai avatar Oct 02 '24 07:10 RamDurgaSai