Hello all, it's been awhile since I've posted here, so I hope everyone has been doing well.

 


I have cross posted this here java - Need to POST data from a client application to my server - Stack Overflow but no answers, and since SO has been extremely slow for the questions I've been asking I am posting here.

 

Here is the post:

 

 

 

I know the title is probably a common question, but I am a bit confused on everything I'm trying to do, so I am trying to piece it together, and figured a common title would be better than a confusing one.

I am basically developing a web application and one part of that is a file uploader. I am using Apache Commons File Upload via the Streaming API, and that all works fine, except I need to access the file I'm uploading, because that contains data to additional files to upload.  I.e., Read File A, get paths to images, upload images with File A to server and save on server.  The API can be found here http://commons.apache.org/proper/commons-fileupload/streaming.html

I was told there is a security risk via the web and would be impossible via a browser, since the user needs to select all files to upload, i cannot tell the browser to upload additional files, so I am left with a client side option.

I am confused if there is a special library I need, or as I have been seeing threads that talk about using the built in UrlConnection Class or http://hc.apache.org/

I basically need to be able to read the file, which technically gives me a path to a Database on the user's system which I then read to get the additional images.  After I get all of that I then  need to post the data as a multipart form as that is what the FileUpload requires.

formmethod="POST"enctype="multipart/form-data"action="fup.cgi">
  File to upload:
<inputtype="file"name="upfile"><br/>
  Notes about the file:
<inputtype="text"name="note"><br/>
 
<br/>
 
<inputtype="submit"value="Press"> to upload the file!
</form>

This is the example found in the Overview section of the Fileupload which can be accessed from the link above.

 

There wouldn't be an issue if the users uploaded all of the data themselves, but since I have to do some of it automatically it causes some "concerns/issues."

 

Basically these files are created and packaged from another application, so the images, and the db will always be in the same place, and that file that they are uploading is a file the other program creates, so everything will always be known, I just need to upload it, and then POST it as enctype="multipart/form-data" So that my servlet can read it and save it on my server.


 

 

So I would appreciate it if anyone had any suggestions on where to begin my journey with this.  I have heard of a few applications like curl and wget that are used for this, but those seem to be more C based.  As mentioned earlier it seeems the httpcomponets from apache might work well, but I want to make sure.

 

 

 

 

 

I appreciate all the help, thank you for your time all.

FacebookTwitterLinkedin
Pin It
Joomla Tutorials for Beginners