title | category | tags |
---|---|---|
Working with images and files |
Data Models |
This how-to explains how you can work with images and files with Mendix. Out of the box Mendix supports uploading of files and images. It also allows you to view images and download files that you uploaded. First you need to create your own domain model and define which entities are images and which are files. This is done by the concept of 'inheritance', sometimes called 'generalization'. By inheriting from 'System.Image' your own entity gets all the properties of the system image entity. This means that you can use the standard platform widgets to upload and view images. The same goes for file documents.
Before you start with this how-to please follow these prerequisites:
- Open your domain model and create an entity called MyImage.
- Double click the entity to open its properties.
- Click Select at the Generalization property to open the entity selector.
- Select System.Image and click the Select button.
- Click OK in the entities property form. Your entity now inherits all properties from the 'System.Image' entity you selected and should look like this:
- Create an overview and detail page to manage objects of the entity that you just created. Your detail page should look like this:
- Open the detail page and double click the ImageUploader to open its properties. On this form you can select the maximum file size, and thumbnail width and height. Mendix automatically generates a thumbnail for the images you upload via the ImageUploader.
- Double click the ImageViewer to open its properties. On this form you can select the default image, width, height and if the viewer should show the thumbnail or full image.
- Open your domain model and create an entity MyDocument.
- Double click the entity to open its properties.
- Click Select at the Generalization property to open the entity selector.
- Select System.FileDocument and click **Select.
**
- Click OK in the entities property form. Your entity now inherits all properties from the System.FileDocument entity you selected and should look like this:
- Create an overview and detail page to manage objects of the entity that you just created. If you don't know how to create those pages, take a look at this how-to. Your detail page should look like this:
- Open the detail page and double click the FileManager to open its properties. On this form you can select the maximum file size and allowed file extensions.
- Create a navigation item for your overview page to start using it. If you don't know how to setup the navigation structure, take a look at this how-to.
- If you turned on security for this application you need to configure page access on both the overview and detail pages. If you don't know how to configure page access, take a look at this how-to.
- Working with images and files
- Creating a basic data layer
- Working With Object Events
- Denormalize Data to Improve Performance
- Setting up data validation
- Finding the Root Cause of Runtime Errors
- Managing your Application Requirements with Mendix
- Scout and Windows 10 Workaround
- Creating a chainable Custom Widget