Store files in Cloud using Java EE

2019-07-21 18:53发布

问题:

Am using CloudBees to deploy my Java EE application. In that I need to write and read files and I wont find any cloud file system from CloudBees. Please suggest me any free cloud file system storage and java code to access that file system.

回答1:

Using jclouds you can store stuff in several different clouds while using a consistent API. http://www.jclouds.org/



回答2:

You can store files - however they will be ephemeral and not shared in the cluster. To achieve that, you would need to store in a DB or s3 or similar (there is also an option of webdav).



回答3:

file system on RUN@Cloud is indeed not persistent neither distributed. File stored there will "disappear" when application is redeployed/restarted and will not be replicated if application scale out on multiple nodes in cluster.

Best option afaik is to use a storage service (amazon s3 to benefit from low network latency from your RUN instance) using jclouds neutral API (http://www.jclouds.org/documentation/quickstart/aws/), that can be configured to use filsystem storage (http://www.jclouds.org/documentation/quickstart/filesystem/) so that you can test on you own computer, and cache filestore content in temp directory - as defined by System.getProperty("java.io.temp") - to get best performances.

This will require a "warm-up" phase for this cache to get populated from filestore, but you'll then get best of both words.