tags:

views:

654

answers:

2

Situation - Upload a simple image file to a server, which clients could later retrieve

1) Designate a FTP Server for the job.

2) HTTP Put - It can directly upload files to a server without the need of a server side
component to handle the bytestream.

3) HTTP Post - handle the bytestream by the server side component.

(interested from a Java EE Perspective...)

A: 

PUT is only appropriate when you know the URL you are putting to.

You could also do:

4) POST to obtain a URL to which you then PUT the file.

edit: how are you going to get the HTTP server to decide whether it is OK to accept a particular PUT request?

Jason S
lets assume, the page from where one would 'put' files could only be accessed by an admin-logged session, so any 'put' request is eligible.
Vaibhav Bajpai
Hmmm... the page "from"? HTTP requests are technically stateless and can arrive out of the blue. Are you depending on cookies for authentication tokens?
Jason S
Also: PUT to a particular URL will (at least from a RESTful standpoint) overwrite content that is already there. I am not sure how Apache and other servers handle this by default, but if your client wants to not overwrite existing content, it needs to check first whether something exists there.
Jason S
Yes, I am depending on cookies for authentication.
Vaibhav Bajpai
A: 

What I usually do (via PHP) is HTTP POST.

And employ PHP's move_uploaded_file() to get it to whatever destination I want.

Ólafur Waage