Accessing the file data in a multipart file upload

221 views
Skip to first unread message

doug livesey

unread,
Feb 25, 2012, 9:45:51 PM2/25/12
to noden...@googlegroups.com
Hi -- I've been trying to handle uploading a file with a service based on Node.native, but have come rather unstuck trying to get at the file data.
It's quite a large file I'm uploading (using curl). I've looped through the header values, but nothing there seems really big enough to be the file data.

The command I'm using to upload the file to my service is:
$ curl --form upload=@features/fixtures/normal-852x1280.jpg http://localhost:3456/process/jpg

The headers and URL info I get back are:
  Accept: */*
  Content-Length: 1326130
  Content-Type: multipart/form-data; boundary=----------------------------7b7cd20eea70
  Expect: 100-continue
  Host: localhost:3456
  User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
  Schema: HTTP
  Host: localhost
  Port: 0
  Path: /process/jpg
  Query: 
  Fragment: 

Could anyone advise me as to where in the request (or wherever else) the file's data is stored?
Or if there's more I need to be doing to get that data?
Sorry if I'm missing something obvious, I'm only just getting to grips with handling HTTP requests.
Thanks,
   Doug.

doug livesey

unread,
Feb 26, 2012, 9:11:34 AM2/26/12
to noden...@googlegroups.com
Hi -- just to update, here, I realised (after some more googling) that the issue could be the "Expect: 100-continue" header, so I disabled that in my cURL call.
I also read some Node.js tuts on multipart file uploads, and saw that they used a multipart class that doesn't yet have an equivalent in Node.native.
So I disabled the multipart bit of the cURL call, too.

So what I'm using, with cURL, now is this:
$ curl -H "Expect:" --data-binary @features/fixtures/normal-852x1280.jpg http://localhost:8080/process/jpg -vvv

My issue now is that the server seems to return 200 (it's not handling anything, currently, I'm just seeing if I can trace what data goes where), but that I get a broken pipe error reported from cURL, like this:
> curl: (55) Send failure: Broken pipe

And, of course, I still can't see where the file data is, so I guess there's something else I need to do, too, to get at it -- maybe implement some callback or other?
Cheers,
   Doug.

Reply all
Reply to author
Forward
0 new messages