Skip to content

Instantly share code, notes, and snippets.

@z11i
Last active June 24, 2025 18:36
Show Gist options
  • Save z11i/fdd874573fc4956c3ee3aad164eddbfe to your computer and use it in GitHub Desktop.
Save z11i/fdd874573fc4956c3ee3aad164eddbfe to your computer and use it in GitHub Desktop.
Use curl to upload a file in a multipart/form-data request, with custom content-type for the file (not the request)
filename='yourfilename'
filetype='text/csv'
token='my oauth token'
url='http://localhost/upload'
curl "$url" \
--form "data=@$filename;type=$filetype" \
--form "name=somename" \
-H "Authorization: Bearer $token"
@lpicquet
Copy link

thanks, that saved me quite the headache!

@eichin
Copy link

eichin commented Jun 24, 2025

Ah! This was a missing piece for firmware upload for old d-link cameras -

--form DownloadFile=@"$fwpath"';type=application/octet-stream'

(along with a bunch of other fields) the ;type= actually made a difference. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment