ClosestStorm / v8cgi

Automatically exported from code.google.com/p/v8cgi
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Image upload doesn't work #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When uploading an image it gets splitted and only a part of an image is
actually received in .data 

Original issue reported on code.google.com by rand0mbond@gmail.com on 21 Jun 2009 at 6:02

GoogleCodeExporter commented 9 years ago
Please provide the imagefile you try to upload so I can test it with proper 
data.

Original comment by ondrej.zara on 21 Jun 2009 at 9:55

GoogleCodeExporter commented 9 years ago
It makes so on any jpeg image, you can test it yourself with the code snippet 
that
you have written in the wiki, just replace the output so that it prints out
item.data.length.

Something like this:
for (var file in request.files) {
  var items = request.files[file];
  if (!(items instanceof Array)) { items = [items]; }
  for (var i=0;i<items.length;i++) {
    var item = items[i];
    response.write("Data lenght: " + item.data.length + "\n");
  }
}

Btw, what is this line for?
if (!(items instanceof Array)) { items = [items]; }

Original comment by rand0mbond@gmail.com on 22 Jun 2009 at 7:11

GoogleCodeExporter commented 9 years ago
Ok, I will test with any image.

The last line is useful for "multiple" file upload feature, supported by Safari 
and
Opera. In this case, one input field (input type="file") can send several files 
at
once - and these will be available as an array.

Original comment by ondrej.zara on 22 Jun 2009 at 7:46

GoogleCodeExporter commented 9 years ago
I was not able to simulate the issue. I tried with a JPG image (attached to this
comment) with size  33227 - and file upload worked normally.

Original comment by ondrej.zara on 22 Jun 2009 at 8:25

Attachments:

GoogleCodeExporter commented 9 years ago
Hmm... for me with this image the code above returns 2654.

It might be because I have revision 444, but I didn't noticed any changes in 
the http
module since that.

How do you think what may cause the problem?

Original comment by rand0mbond@gmail.com on 22 Jun 2009 at 9:15

GoogleCodeExporter commented 9 years ago
I suggest switching to mail-based conversation :) It would be nice to record
(wireshark?) the HTTP POST request to see what is happening. Or, at least, 
record the
request HTTP headers.

Original comment by ondrej.zara on 22 Jun 2009 at 9:25

GoogleCodeExporter commented 9 years ago
Finally acknowledged :)

Original comment by ondrej.zara on 22 Jun 2009 at 1:18

GoogleCodeExporter commented 9 years ago

Original comment by ondrej.zara on 22 Jun 2009 at 1:18

GoogleCodeExporter commented 9 years ago

Original comment by ondrej.zara on 22 Jun 2009 at 2:19