[narwhal] Jack File Upload Problem?

2 views
Skip to first unread message

sk

unread,
May 24, 2010, 2:41:54 AM5/24/10
to Narwhal and Jack
Maybe it's late and I'm missing something simple, but on windows, I'm
unable to get /examples/upload.js to upload anything except text
files.

Binary files (pdfs, jpgs) etc are corrupt and not loadable.

Also, where is config determining where to upload the file? Not sure
why it's defaulting to where it is.

Thanks.

--
You received this message because you are subscribed to the Google Groups "Narwhal and Jack" group.
To post to this group, send email to narw...@googlegroups.com.
To unsubscribe from this group, send email to narwhaljs+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/narwhaljs?hl=en.

sk

unread,
May 24, 2010, 1:13:03 PM5/24/10
to Narwhal and Jack
Ok, I found utils.parseMultipart which answers some questions for me.
Still have corrupt binary files on windows though.

A quick few tests to see if I can GET files shows that I have to
include the binary flag using narwhal's file. Incidentally, I'm not
sure why one would use Jack's file vs Narwhal's, but that's another
issue.

So this works, but without binary I just end up with the url printing
in the body of the browser. Hmm.

return {
status : 200,
headers : {"Content-Type":"image/jpeg"},
body : [File.read("/tmp/pic.jpg", {mode:"b"})]
}

Maybe this is related to the file uploading problems on windows?
Encoding problems? I tried the nodisk option of parseMultiPart but it
doesn't seem to help me either.

I'll keep hunting.

As a sanity check, can you guys confirm that on linux/osx you're able
to upload pdf and jpeg files using the /examples/upload.js and then
open up the TEMP files created by jack without issue? That'll help me
isolate.

sk

unread,
May 24, 2010, 1:21:38 PM5/24/10
to Narwhal and Jack
Looks like it's not just windows. According to this thread by George:

http://groups.google.com/group/narwhaljs/browse_thread/thread/a05b499218a4c717/f298bcef61b19222?lnk=gst&q=upload#f298bcef61b19222

That was back in September. Not sure if his apache commons hack is
still required, but it's good to know I have options.

Scott.

Nathan Stott

unread,
May 24, 2010, 1:26:24 PM5/24/10
to narw...@googlegroups.com
I haven't tried the example and don't have time to load it up at the moment, but I've been using file upload in a beta app for motorpool for quite a few months now and it's working fine for binary files.  The server runs on Ubuntu.  It's using Simple with an nginx proxy infront of it.  It's off of my branch of jack though which last I checked, my changes to parse multipart had not been pulled into master.

sk

unread,
May 24, 2010, 1:48:50 PM5/24/10
to Narwhal and Jack
Just awesome Nathan. Your patch solved the problem. I'm not sure
exactly what the issue was, because you patched for a different reason
than my bug.

I do notice that the original utils file resulted in file uploads that
were of a greater size than the original files. They were of course
corrupt as well. Your patch results in the same size files and after
changing the file extension of the newly created temp file on windows
they load up just fine.

A note that plain text was always working even in the master.

Maybe this is something that should be carried over to the master?
Either way, I'm a happy camper now until the next bug. Ahh...life on
the bleeding edge.

sk

On May 24, 10:26 am, Nathan Stott <nrst...@gmail.com> wrote:
> I haven't tried the example and don't have time to load it up at the moment,
> but I've been using file upload in a beta app for motorpool for quite a few
> months now and it's working fine for binary files.  The server runs on
> Ubuntu.  It's using Simple with an nginx proxy infront of it.  It's off of
> my branch of jack though which last I checked, my changes to parse multipart
> had not been pulled into master.
>
>
>
>
>
> On Mon, May 24, 2010 at 1:21 PM, sk <doyouunderst...@gmail.com> wrote:
> > Looks like it's not just windows.  According to this thread by George:
>
> >http://groups.google.com/group/narwhaljs/browse_thread/thread/a05b499...
> > narwhaljs+...@googlegroups.com<narwhaljs%2Bunsubscribe@googlegroups .com>
> > .
> > > > For more options, visit this group athttp://
> > groups.google.com/group/narwhaljs?hl=en.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > "Narwhal and Jack" group.
> > > To post to this group, send email to narw...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > narwhaljs+...@googlegroups.com<narwhaljs%2Bunsubscribe@googlegroups .com>
> > .
> > > For more options, visit this group athttp://
> > groups.google.com/group/narwhaljs?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Narwhal and Jack" group.
> > To post to this group, send email to narw...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > narwhaljs+...@googlegroups.com<narwhaljs%2Bunsubscribe@googlegroups .com>
> > .

Kris Kowal

unread,
May 24, 2010, 1:49:54 PM5/24/10
to narw...@googlegroups.com
On Mon, May 24, 2010 at 10:13 AM, sk <doyouun...@gmail.com> wrote:
> return {
>        status : 200,
>        headers : {"Content-Type":"image/jpeg"},
>        body : [File.read("/tmp/pic.jpg", {mode:"b"})]
> }

On an unrelated note, this should be equivalent, except potentially
more responsive:

return {
"status": 200,
"headers": {
"Content-Type": "image/jpeg"
},
"body": FILE.open("/tmp/pic.jpg", {mode:"b"})
}

Let me know if that's not the case in "master"; I know it works in
"future" and "migration", but it might need to be back-ported since I
refactored the IO module. It requires forEachable streams.

Kris Kowal

Nathan Stott

unread,
May 24, 2010, 2:01:44 PM5/24/10
to narw...@googlegroups.com
I wrote a thread about my patch to parseMultipart a few weeks back and I also sent pull requests.  Could I reinstate the call to get this merged into master in the official repo?  There is a need for it.

sk

unread,
May 24, 2010, 2:08:39 PM5/24/10
to Narwhal and Jack
Doesn't work in the master.

Firstly, the incompatible api through me, where open has 3 args not
two, and so mode is a string and not an object...

Also, the first example returns body in an array whereas yours
doesn't. Either that's my misunderstanding or a typo? Either way I
tried both.

body: File.open("/tmp/pic.jpg", "b")
results in blank page.

body:[File.open("/tmp/pic.jpg", "b")]
results in TypeError: Cannot find function toByteString in object
[object Object]

body:[File.read("/tmp/pic.jpg", "b")]
works.

What is the main difference between narwhal's file and jack's?

On May 24, 10:49 am, Kris Kowal <kris.ko...@cixar.com> wrote:

Tom Robinson

unread,
May 26, 2010, 11:21:41 PM5/26/10
to narw...@googlegroups.com
I've merge the changes in your master branch. Sorry for the delay. Anyone else have contributions I've missed?

-tom

Paul Baumgart

unread,
May 27, 2010, 1:06:03 AM5/27/10
to narw...@googlegroups.com
A few I still had lying around:

add objective-j, cappuccino, and plist mime-types
http://github.com/paulbaumgart/jack/commit/464890d63f1e4852aa28cd70e2083b1d2fd62ee9

fix running tests from command line
http://github.com/paulbaumgart/jack/commit/41883b018bd01b58ddb27bcbbd81e44ad70acf78

Add validation for response properties and throw an appropriate error if
validation fails.
http://github.com/paulbaumgart/jack/commit/c4c26d939fe055b9e783db40a725e2fb02d41006

add response validation tests
http://github.com/paulbaumgart/jack/commit/f5d72795fb4104d61b13c61487f0532531ab133a

----------

These need to be reviewed closely, because I'm not very confident
about whether I understood the intent of the code correctly:

fix session retrieval for cookie handler
http://github.com/paulbaumgart/jack/commit/c75f8bd50a699be4e14d4839efe9f12cc1d1604c

update cookie handler tests to reflect use of Session object
http://github.com/paulbaumgart/jack/commit/1e8ae663f74dd290e89164174dbfd2e870534d2c

update utils-tests to make multipartbinary file length test pass
http://github.com/paulbaumgart/jack/commit/fc1b9708e82556773879dcf1cf4e22efb0f91cd2

----------

And a really minor one, just replacing == with ===:

update detection for whether jackup is being run as a standalone program
http://github.com/paulbaumgart/jack/commit/55697bf8a45089d9adeb2a3e167b1e0874377b04


Paul

Tom Robinson

unread,
May 27, 2010, 10:44:59 PM5/27/10
to narw...@googlegroups.com
First two look good. I left comments on the others.
Reply all
Reply to author
Forward
0 new messages