This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have David & Dawn Griffiths on-line!
See this thread for details.
Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

HTTP PUT File Uploads

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

I have written code in the past in 3 non-Java scripting languages - PHP, Perl and Python that deals with uploading a file (to a server) through PUT method. I was wondering if it is possible in Java. I'm also confused with the subtleties of the doPut() method. Could it be put to some use here?

Thank you all for your replies.

Regards,
Abhijit.


[Programmed in 4 languages ; Still In Love with Java ]
 
Saloon Keeper
Posts: 7173
166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are you trying to achieve using PUT that you couldn't achieve using POST?
 
Saloon Keeper
Posts: 24553
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes it is, although PUT theoretically has a limit on uploaded data (URL) size that POST does not.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Yes it is, although PUT theoretically has a limit on uploaded data (URL) size that POST does not.



Wha??? Where do you find that documented. Perhaps you meant that the URL size limits the description of the resource location. PUT contents are in the body of the request and are thus not limited by the URL.

Wikipedia HTTP methods PUT

You can certainly use PUT but you can't generate a PUT from a HTML form, you would have to write your own client. You might look at the Jersey toolkit.

Bill
 
Tim Holloway
Saloon Keeper
Posts: 24553
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, William, you've got me.

The problem with PUT is that some servers had a limited-size buffer to catch the URL in - usually somewhere between 1025 and 4096 characters. So a file embedded in the URL would have to be small enough that the total URL wouldn't give the server indigestion.

You can certainly generate PUT requests from an HTML form. People have been doing it since Day 1. Just specify "method=PUT" on the form element.

However, all of the above is predicated on a straightforward PUT. If the payload file was embedded in a cookie or other request header, then that could change things. But to set up a PUT that did that would DEFINITELY require a custom client.
 
Sheriff
Posts: 67595
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:The problem with PUT is that some servers had a limited-size buffer to catch the URL in - usually somewhere between 1025 and 4096 characters. So a file embedded in the URL would have to be small enough that the total URL wouldn't give the server indigestion.


The payload in a PUT is in the request body so URL length restrictions are not a problem.

You can certainly generate PUT requests from an HTML form. People have been doing it since Day 1. Just specify "method=PUT" on the form element.


HTML forms do not support PUT. You can specify PUT as the form method but the browser will issue a GET.

To generate a PUT from the browsers, you can do so with an Ajax request (at least in modern browsers -- older browsers also changed PUT to GET in Ajax requests).

 
Tim Holloway
Saloon Keeper
Posts: 24553
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know my PUTs from my GETs. Never mind.
 
reply
    Bookmark Topic Watch Topic
  • New Topic