cURLParse cURL Converter

Example: Multipart File Upload with cURL

cURLParse — Convert cURL Commands to Python, Node.js, Go & Rust Guides · Updated 2026-10-01 · All guides
curl -X POST https://files.example.com/upload \
  -H 'Authorization: Bearer ***' \
  -F '[email protected];type=application/pdf' \
  -F 'metadata={"tag":"q3"}'
  • -F builds multipart/form-data (binary-safe); do not use -d for files — --data-binary @file works only when the API wants raw bytes, not a form.
  • ;type= sets that part's Content-Type. Omit it and curl guesses by extension, which is fine for PDFs and catastrophic for CSVs.
  • Converted to Node fetch: expect a FormData() + Blob construction, no manual boundary. If a converter emits a hand-built multipart/form-data string with a literal boundary, that's a bug in the converter — ours isn't.

FAQ

Why is my upload corrupted when sent as raw bytes? -d @file treats content as a form-urlencoded string and will mangle binary. -F (or --form) is the multipart, binary-safe path.

Can I upload without reading the whole file into memory? curl streams from disk either way. In Node, pass a Blob backed by fs.openAsBlob() (or a File) to FormData for the same effect.

What does the converted Go code do for -F? It builds a mime.NewWriter multipart writer — see the curl-to-go route for the generated shape.

Developer Sponsor / Partner
Copied to clipboard!