S3 Attachment Storageby IT-Projects LLC https://it-projects.info , Ildar Nasyrov https://it-projects.info
|Also available in version||v 13.0 v 12.0 v 11.0 v 10.0|
S3 Attachment Storage
Upload attachments on Amazon S3
- The module allows to upload the attachments in Amazon S3 automatically without storing them in Odoo database. It will allow to reduce the load on your server. Attachments will be uploaded on S3 depending on the condition you specified in Odoo settings. So you can choose and manage which type of attachments should be uploaded on S3.
- It is useful in cases where your database was crashed, because you will be able to easily restore all attachments from external storage at any time.
- The possibility to use one external storage for any number of databases.
How it works
E.g., go to Sales → Products menu and open an item. Upload any images to the product.
At this moment in the Settings → Database Structure → Attachments menu the attachments will be created with the corresponding URL.
Then open Amazon S3 bucket and see uploaded attachments.
The attachments will be loaded to Odoo DB from S3 server by using URL and they will not be stored in your DB.
Before using you need to make some configuration:
- Install boto3 library and get credentials for it by using this quickstart instruction https://boto3.readthedocs.io/en/latest/guide/quickstart.html
- Grant access to your S3 bucket using this instruction http://mikeferrier.com/2011/10/27/granting-access-to-a-single-s3-bucket-using-amazon-iam and set bucket as public
- Enable technical features https://odoo-development.readthedocs.io/en/latest/odoo/usage/technical-features.html
Open menu Settings → Technical → Database Structure → S3 Settings and specify the following parameters:
s3.bucket: the name of your bucket (e.g. mybucket)
s3.condition: only the attachments that meet the condition will be sent to S3 (e.g.
[('res_model', 'in', ['product.image'])]) - it is actually the way of specifying the models with
fields.Binaryfields that should be stored on S3 instead of local file storage or db. Don't specify anything if you want to store all your attachment data from
fields.Binaryand also ordinary attachments on S3.
s3.access_key_id: S3 access key ID
s3.secret_key: S3 secret access key
- Click on
Upload existing attachmentsif you want to upload attachments you had before installation the module
You will get free support and assistance in case of any issues
S3 Attachment Storage
Install this module in a usual way
Using this quickstart instruction install boto3 library and get credentials for it
Using this instruction grant access to your s3 bucket
Set your S3 bucket as public
Optionaly, add following parameter to prevent heavy logs from boto3 library:
- To enable the feature of linking existing urls to binary fields:
- Start Odoo with --load=web,ir_attachment_url or set the server_wide_modules option in The Odoo configuration file:
[options] # (...) server_wide_modules = web,ir_attachment_url # (...)
- Enable technical features
- Open menu Settings >> Parameters >> System Parameters and specify the following parameters there
- s3.bucket: the name of your bucket (e.g. mybucket)
- s3.condition: only the attachments that meet the condition will be sent to s3 (e.g. [('res_model', 'in', ['product.image'])]) - it is actually the way of specifying the models with fields.Binary fields that should be stored on s3 instead of local file storage or db. Don't specify anything if you want to store all your attachment data from fields.Binary and also ordinary attachments on s3.
- s3.access_key_id: S3 access key ID
- s3.secret_key: S3 secret access key
The settings are also available from the Settings >> Technical >> Database Structure >> S3 Settings.
Depending on what you have in the s3.condition setting, some or all attachments will be uploaded on your s3. For example upload by editing product template from Sales >> Product menu some image for your product. By doing this you have uploaded image on your s3 storage. In this case you should also install ir_attachment_url module to be able to see products' images in odoo backend. Because by default odoo doesn't use urls in its backend. It uses only local stored files or stored db data.
Upload existing attachments
- To upload existing attachments go to the Settings >> Technical >> Database Structure >> S3 Settings menu and click on the [Upload existing attachments] button there
- To add link of existing S3 bucket object to binary fields of existing odoo records:
- Take Link urls from Amazon. If you open Overview of the object on Amazon you should see it at the bottom of the page
- make sure that you have properly configured your odoo, see the Configuration section of this instruction once again in the To enable feature of linking... part
- to link objects one-by-one from an odoo backend (this option is only available for images attachments):
- In any place where you can upload images to odoo (i.e. from Sales >> Sales >> Products when you select a product and push [Edit] button there and hover your mouse pointer under the place on a form view where an image should be) along with standard pencil and trash bin buttons you can see the additional [@] button. Click on this button.
- Copy-paste your url for image and click [Save] button
- to link objects in batch you may use default import/export feature in odoo:
- for example, export records of model product.template. Choose image field in the export dialog and save in file.
- open the file with your favorite text editor and paste urls into image column there
- import records from the edited CSV file
- now when you open from Sales >> Sales >> Products your product form, you should see the image you specified by url in the file
Please log in to comment on this module
- The author can leave a single reply to each comment.
- This section is meant to ask simple questions or leave a rating. Every report of a problem experienced while using the module should be addressed to the author directly (refer to the following point).
- If you want to start a discussion with the author or have a question related to your purchase, please use the support page.