Media Archive

Most databases are really good at storing and retrieving text, numbers and dates. To be a true database for the web (and beyond), we have added a Media Archive as an integral part of

A database in has a predefined space for storing media files. You can upload any file format to the archive. The media content is shown as preview image thumbnails or document icons indicating file type.

In addition to uploading and storing the images in the database, automatically produces various formats for displaying images:

  • Thumbnail format - 128 pixels width
  • Web format - 640 pixels width
  • Full scale format - no compression


Using media in your application

Data fields in a "record" can have a data type of image or file. The images/files selected, will then be linked to the record.

In our example Collection we have a field called Photos of Data type image, you can select any image from the media archive to attach to this particular record.


The media files are stored as IDs in an array on the current record in the following JSON format:

    "_id": "5602647c7f98025500000003",
    "name": "Ut quo",
    "description": "Accusantium voluptates ...",
    "photos": [
    "serialno": "15148-6862",

Please note the the media ID is always stored in an array, even if it's only one ID.

Accessing images via API

Images are retrieved via URLs (here for the database named rdb-simpledb):

You can also use the unique ID to retrieve the same image:

Optional parameter ?s=t or ?s=w returns the image as thumbnail or web size

If we only want the image metadata we can use an additional route (you must be logged in or use an API key to call this URL):

This produces a full dump of the image metadata, an example is shown below:

    "_id": "560263607f98025500000000",
    "_created": "2015-09-23T08:31:28.227Z",
    "_createdby": "canuto",
    "app": "rdb-simpledb",
    "origname": "3dprinter2.jpg",
    "file": "0a27238ec6285629e4578b2b6c8b3b3f3dprinter2.jpg",
    "fullname": "/rdb-simpledb/rdb-simpledb/product/5602603651366f310000029a/0a27238ec6285629e4578b2b6c8b3b3f3dprinter2.jpg",
    "exif": {
      "file name": "0a27238ec6285629e4578b2b6c8b3b3f3dprinter2.jpg",
      "file size": "94 kB",
      ..."color components": "3",
      "y cb cr sub sampling": "YCbCr4:4:4 (1 1)",
      "image size": "695x470"
    "owner": "rdb-simpledb",
    "ref_id": "5602603651366f310000029a",
    "ref_card": "product",
    "ref_field": "photos",
    "_version": 0,
    "mediatype": "image",
    "access_key": "21641469347282646884"

You can fetch metadata for multiple media files like this:*/meta?ids=560263555f98025500000001, 560263607f98025500000000

If you ommit the "ids" parameter, metadata for the entire Media Archive will be retrieved.

Query the media archive API

The media archive can also be queried similar to database collections using the request url parameters q={} and h={}. Consider the example request url below querying the media archive for the first 10 files with byte size > 3 kb, showing only 3 fields and sorted by file size.

https://<dbname>*/meta?q={"filesize": {"$gt": 3072}}&h={"$max":10, "$orderby":{"filesize":-1}, "$fields": {"origname": 1, "filesize": 1, "_id": 1}}

Example output:

        "_id": "5ba518dbf936ff7a00002c39",
        "filesize": 3847325,
        "origname": "dynamicsite-templ-frontpage-1.png",
        "_id": "5a1dd509a3c5b06b000052f5",
        "filesize": 3271090,
        "origname": "campaign3.png",

Media Archive security

If the Media Archive access is set to restricted in the API settings, files can still be retrieved using a URL but will require an extra "key" parameter: or filename)?key=22631469345172666884

Keys can be found in the "meta" info (see above, field "access_key") or by clicking the icon on files in the Media Archive. The correct "key" parameter will also be added to the URL when you click "Copy URL to clipboard".

For posting files to the database via the API, read this blogpost.