简体   繁体   中英

Image Upload in java (struts2/struts1/spring mvc)

I have one website with jsp, java, struts2. I wanted to upload a profile image into server . This is possible to upload into the server and link with the profile. I want to store all the uploaded images in another server . For example server A hosts the java web application. server B is a purchased space server and I want to upload the images from web application to server B. And the path and link 'll keep in server A database. Is it possible to do this same or any better idea is appreciated.

Thanks in advance.

This is a very popular design. Consider the fact that if one of the two servers (A or B) is down, your site will not work, unless server B is mirrored properly.

Links to images can be anywhere on the web, as long as you provide the full path in the link. Also, make sure that server B can withstand the load, since every request for a page on server A with a link to an image on server B will obviously require both servers to respond.

Yes , I have found the solution. Approach #1: In java application you can upload your image to your current server(A) and store with c://somefolder/ . Then from the java application transfer the image using httpclient to a different server (B) which is in php/mysql and another domain name.(Php process is easy to store and access). After the transfer process get the result ,file name ,url and store it with your server A database. And in successful transfer delete the file from server A folder. Now u can user the image path as server B domainname/appname/imagepath .

Approach #2: The same process you can use with amazon web services. (if you don't want to use the second domain name of yours.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM