aspose file tools*
The moose likes GWT and the fly likes Upload large files via HTTP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "Upload large files via HTTP" Watch "Upload large files via HTTP" New topic
Author

Upload large files via HTTP

Marchi Bu
Greenhorn

Joined: Jul 19, 2011
Posts: 4
Hello,

I need to upload large files to a web server wit the GWT.

All across the internet, I found dozens of examples that pretend like the main problem lies with coding the server, while I have the biggest problem with the client.

I am not using RPC, but simply the request builder on the client and a PHP backend on the server (no servlets).

I know you can use the FileUpload widget. I also know the HTML-Stuff (how you need a form element, too, and how the GWT compiler will create an "input-type:file" element). Since JavaScript does not allow you to access your file system (read/write) directly, I assume that the submit() method of the Form automatically instructs the browser to read the file from disk and create the approriate HTTP header and body to send to the server. I know that will incorporate the file into the body with the proper encoding.
The way I understand it, there is no need to implement any of the onSubmit() or onSubmitSucceeded() methods (sorry, don't know their proper names now) of the Form widget. Unless you want to control input fields or throw messages etc.

I wonder what will happen if that file is bigger than the prescribed HTTP packet size? Will the rest of the file simply be cut off?

But the big question is, how do I upload files larger than 10MB over HTTP using the GWT? I don't want to set up an FTP server (no extra ports by my employer).
Also, since you cannot use JavaScript to split the video into pieces on client side (in the background, without the user noticing), I cannot think of a way of doing this.

And yet, you can do this in Youtube. How? Does Youtube use FTP? Seems unlikely, since the client might have decided to firewall FTP traffic (which Youtube should be prepared for).
Or does Youtube use ActiveX?

Please, I really need to know how to do this.


Thanks in advance.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10375
    
    8

Welcome to the Ranch.

Is your question about uploading large files using the file upload widget or about how the underlying technology works. I reread a few times and am still a bit confused.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Marchi Bu
Greenhorn

Joined: Jul 19, 2011
Posts: 4
Maneesh Godbole wrote:Welcome to the Ranch.

Is your question about uploading large files using the file upload widget or about how the underlying technology works. I reread a few times and am still a bit confused.


Well, primarily, it is about uploading large files using the GWT. Since the file upload widget seems to be the easiest potential way of doing this, it is also about using the file upload widget for this purpose.

Moreover, since, in theory, the whole thing seems to be impossible, some questions arouse how this technology actually works for places like youtube. I cannot explain how youtube even accomplishes its large file uploads, given the limited HTML package size and no way of reading and writing the file system with Java Script.

Can you help me with this?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

You refer to something called "HTTP packet size" or "HTTP package size". Can you explain what you think this term (or these terms, if they are different) mean?
Marchi Bu
Greenhorn

Joined: Jul 19, 2011
Posts: 4
Paul Clapham wrote:You refer to something called "HTTP packet size" or "HTTP package size". Can you explain what you think this term (or these terms, if they are different) mean?


Well, there usually is a limit of how big each HTTP packet is allowed to be. If there is no such official limitation in the according RFC, there surely is one in PHP (on server side). You can configure it to be 10MB at the maximum from what I've read. This means that any file larger than that has to be split up into smaller parts so they can be placed into multiple HTTP packets.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Okay. But that's an internal detail of the computer's HTTP stack and users shouldn't need to concern themselves with it. Or have you found in practice that your file uploads are being truncated at a size which you believe is this number, or found some documentation which suggests you have to fiddle with this number to be allowed to upload large files?
Marchi Bu
Greenhorn

Joined: Jul 19, 2011
Posts: 4
Paul Clapham wrote:Okay. But that's an internal detail of the computer's HTTP stack and users shouldn't need to concern themselves with it. Or have you found in practice that your file uploads are being truncated at a size which you believe is this number, or found some documentation which suggests you have to fiddle with this number to be allowed to upload large files?


Hmm...looking at the PHP and the HTTP documentations, it seems there is really no limit on this. Maybe what I had read before referred to old versions of PHP, but neither the php.ini's UPLOAD_MAX_FILESIZE nor the HTTP (content-length header field have an explicitly stated limit to be used.

So in theory, this should work (provided you have enough memory on server to manage simultaneously several uploads of videos sized several hundreds of megabytes each).
I'll see how this works out in practice, and at worst, implement some kind of waiting queue if the memory is too busy.

Thanks so far!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Yes, servers can be written to limit the size of file uploads (otherwise you could have a denial-of-service attack by somebody uploading a file which was ridiculously enormous). But that's not a limit which comes from HTTP, it's a limit which the servers themselves can choose to enforce. So yeah, give it a try and see how it goes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Upload large files via HTTP