Uploading directories fails with MalformedStreamException: Stream ended unexpectedly

968 views
Skip to first unread message

Andreas Joseph Krogh

unread,
Jul 31, 2017, 8:48:26 AM7/31/17
to lif...@googlegroups.com
Hi all.
 
I'm trying to upload directories using the new proposed HTML5 spec, supported by Chrome:
 
 
but it fails with:
org.apache.commons.fileupload.MultipartStream$MalformedStreamException: Stream ended unexpectedly
       at org.apache.commons.fileupload.MultipartStream$ItemInputStream.makeAvailable(MultipartStream.java:1005)
       at org.apache.commons.fileupload.MultipartStream$ItemInputStream.read(MultipartStream.java:903)
       at java.io.InputStream.read(InputStream.java:101)


 
The HTTP-request payload looks like this:
 
------WebKitFormBoundaryEGeYs7NXIdKP92K3
Content-Disposition: form-data; name="aaxmlrequest"
true
------WebKitFormBoundaryEGeYs7NXIdKP92K3
Content-Disposition: form-data; name="upload"; filename="tmp"
Content-Type: application/octet-stream

------WebKitFormBoundaryEGeYs7NXIdKP92K3--
 
When uploading a regular file the HTTP-request payload looks like this:
------WebKitFormBoundary8Q0M8sFUNiid45oB
Content-Disposition: form-data; name="aaxmlrequest"
true
------WebKitFormBoundary8Q0M8sFUNiid45oB
Content-Disposition: form-data; name="upload"; filename="brscan-skey-0.2.4-1.amd64.deb"
Content-Type: application/vnd.debian.binary-package

------WebKitFormBoundary8Q0M8sFUNiid45oB--
 
I'm using commons-fileupload-1.3.3.
 
It seems it's an apache-commons-filupload issue and not directly related to Lift. Has anyone gotten uploading directories to work with Lift? Are there other file-upload backends than apache-commons which supports this?
 
Thanks.
 
--
Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963

Matt Farmer

unread,
Jul 31, 2017, 12:55:21 PM7/31/17
to lif...@googlegroups.com
Just curious: Does it behave differently if you upload all the contents of a directory individually instead of the directory itself?

I've generally avoided doing this because it's always seemed to be finicky, so unfortunately I can't provide much guidance on backends that would work well for this. :/

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Antonio Salazar Cardozo

unread,
Jul 31, 2017, 2:46:55 PM7/31/17
to Lift
Strange, the Chrome multipart upload filename for the directory version doesn't seem to adhere
to the example in the draft proposal anyway, right?
Thanks,
Antonio

Andreas Joseph Krogh

unread,
Jul 31, 2017, 3:51:07 PM7/31/17
to Matt Farmer, lif...@googlegroups.com
På mandag 31. juli 2017 kl. 18:55:05, skrev Matt Farmer <ma...@frmr.me>:
Just curious: Does it behave differently if you upload all the contents of a directory individually instead of the directory itself?
 
I've generally avoided doing this because it's always seemed to be finicky, so unfortunately I can't provide much guidance on backends that would work well for this. :/
 
Hm, it seems it was because I wasn't traversing the directory in JavaScript so I was sending the folder down as a file with no content, which is not supported. When traversing the folder-structure client-side (JS) and sending all files down it works. I have to split the filnames on fileSeparator('/' or '\' as the client might be Unix or Windows) serverside when processing the FileParamHolder but that's a no-brainer.

Antonio Salazar Cardozo

unread,
Jul 31, 2017, 4:33:19 PM7/31/17
to Lift, ma...@frmr.me
Nice!
Reply all
Reply to author
Forward
0 new messages