I'm trying to use curl to batch upload to YouTube, following the API spec here; in short, it requires a multipart POST request with metadata in XML format and Content-Type of application/atom+xml; charset=UTF-8
, followed by the video data itself.
My current command line (fetching the metadata from upl.xml and the video from upl.mkv) looks something like this:
curl -s -F "[email protected]" -F "[email protected]" -H 'GData-Version: 2' -H 'Authorization: GoogleLogin auth=<AUTH>' -H 'Slug: upl.mkv' -H 'X-GData-Key: key=<KEY>' http://uploads.gdata.youtube.com/feeds/api/users/default/uploads
When I check the actual request that's being sent with --trace
, it looks as though both files are being sent in the correct order, but the Content-Type of the metadata is set to application/octet-stream
; the upload completes as expected, but YouTube refuses to process the video.
If I try to submit upl.xml with --data
, --data-ascii
, --form-string
etc. I just get an assortment of other errors, which leads me to believe it's down to the incorrect Content-Type. If I ignore the metadata and just send the video file it works fine, but unfortunately this doesn't solve my problem.
Am I missing something here, and if not is it possible to do this without breaking out libcurl?