ChatiumFor developersPlaygroundPricing
Sign in

Heap.ImageFile

Declares a field for convenient storage and manipulation of the identifier of an image file uploaded to the file storage.

This is a non-standard type in the JSON schema. It is stored in the database as a string identifier of the file in the storage, obtained when uploading the file using the attachMedia action, and at runtime, it is represented by an instance of the special class StorageImageFile. To write a value to the database, you need to pass the file identifier in the storage.

You can read more about working with files in the relevant section of the guide.

Usage / Signature

import { Heap } from '@app/heap'
Heap.ImageFile()

Return Value

JSON schema for a string field.

Examples

List of Product Images
const products = Heap.Table('products', {
  images: Heap.NonRequired(
    Heap.Array(Heap.ImageFile()),
    [],
  ),
})
product.images.map(file =>
  <image src={file.getThumbnailSrc()} />
)