ADempiere has very good mechanism to upload, store and view images. Also, image management is integrated smoothly with the standard ADempiere windows, which provides seamless management of images on the web platform. All the images are stored in database and on need basis images are retrieved from the database to show them on the web application. Even though it appears good, it has following limitations
- Image rendering will be slower as it has to load from application database
- As number of images and size of image increases, the database will have performance issues
Amazon S3 provides a scalable option for storing of images or static content and rendering of images on screen will also be faster with Amazon Cloud Front.
Scope of this article
This article talks about integration of Amazon S3 and ADempiere to ensure that adding documents and images has very less impact on the application server.
- AmazonS3 API
- Adempiere 3.6.0 or above
Following jars required
Step 1: Changes in ADempiere
We need to make changes in ADempiere to connect to remote storage system that is Amazon’s Simple Storage Service (S3), and use its API to store Adempiere’s Image into Amazon’s storage location. We will use AmazonS3 API (AWS SDK for Java) to achieve this.
- Add required jars into your project build path.
- Create system configurator variable, which will act as a switch for Storage functionality. Based on this system configuration parameter, system will decide either to use standard storage or amazon stroage
- Create AWSEnv.properties file, which holds secret key and access key. We can enhance standard Adempiere.properties file to hold this new variables. But that will lead to more code changes.
- Prepare a new util class which will have generic methods to connect to Amazon S3 (AmazonS3Client()), to create buckets (createBucket()), to store files (putObject()) and to retrieve files (generatePresignedUrl()). Consider following items while preparing generic methods
- Once image is stored in Amazon S3 (putObject()), it returns unique URL for this image (generatePresignedUrl()), store this URL in image object of Adempiere to render on web browser
- Any entity stored in Amazon S3 will have definite life period, you may like to mention that as per the project need
- You can create your own folder structure in Amazon S3, to identify files uniquely
- Make code changes in Image Model class to invoke generic methods defined in previous step
After making all the above mentioned changes, ADempiere is ready to store/render images to/from Amazon S3 respectively
To use AmazonS3 you need to sign up for an Amazon account. It provides you Access Key & Secret Key.
Step 2: Let us see how it works in ADempiere
Let us store one Image file into Amazon’s secured storage location and see how it renders into web browser
- Login into ADempiere with GardenAdmin role
- Open business partner window and click on ‘Logo’ widget to upload business partner’s image
- Click on the select file and browse for the desired image
- Click on upload and save the file on Amazon and log into AWS management console and verify whether image is uploaded or not
- Now in business partner window, you can see the uploaded image being rendered in ‘Logo’ widget
With the minor changes, the image management in ADempiere becomes more effective and efficient. The end user experience while viewing contents consisting of images or static content on web improves significantly.
Walking Tree promotes ADempiere and we support the users as well as the developers to ensure that the business is able to take complete advantage of ADempiere’s wonderful capability. In case you are looking for a professional assistance then do visit our website to get in touch with us.