How To Serve Uploaded Images From OpenShift DATA_DIR

风格不统一 提交于 2019-12-31 02:30:08

问题


My app runs on JBoss EAP and I want to upload images to the OPENSHIFT_DATA_DIR and then save their relative paths in the MySQL DB because I need to construct a path to the images and later serve them to the browser when needed.

If my OPENSHIFT_DATA_DIR path is /var/lib/openshift/5364c54ce0b8cd80180001f7/app-root/data/ and I want schoolpics/federaluniversity/uniben-1/ inside it to save a file logo.png such that the full path will be

/var/lib/openshift/5364c54ce0b8cd80180001f7/app-root/data/schoolpics/federaluniversity/uniben-1/logo.png

How to achieve this in term of storing in database, and opening using URL of image in a web page, since the OPENSHIFT_DATA_DIR seems to be outside the webroot of the app.


回答1:


My solution to this issue was to create a servlet that would serve the images from the OPENSHIFT_DATA_DIR, the servlet also supplies a way to write the images to the OPENSHIFT_DATA_DIR also, you can check out this forum post for more information: https://www.openshift.com/forums/openshift/how-to-upload-and-serve-files-using-java-servlets-on-openshift



来源:https://stackoverflow.com/questions/24163138/how-to-serve-uploaded-images-from-openshift-data-dir

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!