Upload files to storyblok.
- Setup Storyblok API
- Add Storyblok folder and connect with API and model
Once the asset field is updated, the file will be uploaded to Storyblok folder. The asset url and id are stored on the record as 'document_url' and storyblok_asset_id.
- Inherit the Storyblok asset mixin in model with asset field:
class Partner(models.Model):
_name = "res.partner"
_inherit = ["res.partner", "storyblok.asset.mixin"]
- Define an inverse method of the asset field:
image_1920 = fields.Image(inverse="_inverse_image_1920")
def _inverse_image_1920(self):
self.upload_asset(self.image_1920)
- To prevent upload use storyblok_update context.
self.with_context(storyblok_upload=False).write({"image_1920": filepath})
This module is maintained by Mint System GmbH.
For support and more information, please visit our Website.