LogoLogo
  • Introduction
  • Features
  • Getting Started
    • Cortex User Guide
      • Organizations
      • Log in
      • Generate an API key
      • Make your first API request
      • Configure the org settings
      • Set up a data model
        • Create custom objects
        • Add custom properties
      • One-to-many relationships
      • Read and write data
      • Making a Request
      • Handling responses
      • Authentication
      • Two-factor authentication
      • Set third-party cookies
      • Connections
      • Upload files
      • Cortex iOS
      • Get started with Swift
      • Cortex service accounts
      • Cortex developer tools
      • Automated Account Notifications
  • Cortex API
    • Overview
    • Objects
      • Objects Overview
      • Organization
      • Account
      • Connections
      • Notifications
      • Stats
      • Logs
      • Export
      • Events
      • Room
    • Object Definition
      • Object Properties
        • Any
        • Binary
        • Boolean
        • Date
        • Document
        • File
        • Geometry
        • List
        • Number
        • ObjectId
        • Reference
        • String
    • Object Types
    • Access Control
    • Querying
      • Query Operators
      • Property Selection
      • Property Access
    • Aggregating
      • Aggregation Operators
    • Scripting
      • Script Types
      • Script Limits
      • ObjectId
      • CortexObject
        • Accounts
        • Views
      • Cursors
      • Operations
      • Script Modules
        • API Module
        • Base64 Module
        • Cache Module
        • Connections Module
        • Console Module
        • Consts Module
        • Counters Module
        • Crypto Module
        • HTTP Module
        • Logger Module
        • Notifications Module
        • Request Module
        • Response Module
        • SAML Module
        • Schemas Modules
        • Script Module
        • Session Module
        • Util.id Module
        • Util.ip Module
        • Util.paths Module
        • XML Module
        • Developer
        • Config
        • Renderer
        • SFTP
        • FTP
        • DB
          • Cursors
          • Driver
      • Static Methods
        • Accounts
        • Views
        • Cursors
      • Audit
      • Environments
      • HTTP Driver
      • Notifications
        • Firebase Cloud Messaging (FCM)
        • Tencent Push Notification Service Configuration
      • Televisit
      • Transforms
      • Localization
      • Available Javascript Libraries
    • Decorators
      • Runtime
        • Acl
        • As
        • Log
        • Profile
      • Static
        • Env
        • Job
        • Object
        • On
        • Policy
        • Route
        • Transform
        • Trigger
    • Expressions
      • Primer
      • Pipelines
      • Operators
      • Accumulators
      • Variables
      • Conditionals
      • Transforms
      • Triggers
      • On
      • Events
    • Faults
      • Fault Reference
  • Releases
    • Cortex Release Notes
      • Cortex API 2.28.3 (R3.4.6)
      • Cortex API 2.28.1 (R3.4.3)
      • Cortex API 2.27.2 (R3.4.1)
      • Cortex API 2.27.1 (R3.3.5)
      • SQL DB Connector 1.3.4 (R3.3.3)
      • Cortex API 2.26.2 (R3.3.1)
      • Cortex API 2.26.1 (R3.2.2)
      • Cortex API 2.26.0 (R3.2.1)
      • SQL DB Connector 1.3.3
      • Cortex API 2.25.0 (R3.1.1)
      • SQL DB Connector 1.3.2 (R3.1.0)
      • Cortex API 2.24.2 (R3.0.2)
      • SQL DB Connector 1.3.1 (R3.0.0)
      • Cortex API 2.24.1 (R2.3.3)
      • Cortex API 2.24.0 (R2.3.2)
      • SQL DB Connector 1.3.0 (R2.3.0)
      • Cortex API 2.23.0 (R2.2.4)
      • SQL DB Connector 1.2.0 (R2.2.0)
      • Cortex API 2.22.2 (R2.1.2)
      • Cortex API 2.22.1 and SQL DB Connector 1.1.1 (R2.0.1)
      • Cortex API 2.22.0
      • Cortex API 2.21.3
      • Cortex API 2.21.2
      • Cortex Web 4.16.0
      • Cortex Web 4.15.1
      • Cortex API 2.20.1
      • Cortex Web 4.14.0
      • Cortex Renderer 1.3.3
      • Cortex API 2.19.4
      • Cortex API 2.19.3 and Cortex Web 4.13.1
      • Cortex Renderer 1.3.2
      • Cortex API 2.19.1
      • Cortex API 2.18.0
      • Cortex API 2.17.6
      • Cortex API 2.17.5
      • Cortex API 2.17.4
      • Cortex API 2.17.3
      • Cortex API 2.17.2
      • Cortex API 2.17.1
      • Cortex API 2.16.0
      • Cortex API 2.15.9
      • Cortex API 2.15.8-1
      • Cortex 2.15.8
      • Cortex API 2.18.1
      • Cortex API 2.16.1
      • Cortex Renderer 1.3.1
      • Cortex Renderer 1.3.0
      • Cortex Renderer 1.2.2
      • Cortex Renderer 1.2.1
      • Cortex Renderer 1.2.0
    • Third-Party License Attribution

© 2025 Medable, Inc. All rights reserved.

On this page
  • Facets
  • Uploads

Was this helpful?

  1. Getting Started
  2. Cortex User Guide

Upload files

Last updated 3 years ago

Was this helpful?

Facets

Use an existing facet when you want to copy a file property. Note when creating file properties using existing facets, the source data is always copied. The following are all examples of valid content facet reference property values:

  • "/accounts/5a4feb0bc4a54066c8f4c1c4/image/content"

  • "accounts/5a4feb0bc4a54066c8f4c1c4/image/content"

  • "facet:///accounts/5a4feb0bc4a54066c8f4c1c4/image/content"

  • "facet://accounts/5a4feb0bc4a54066c8f4c1c4/image/content"

  • {source: "facet", filename: "thing.png", path: "/accounts/5a4feb0bc4a54066c8f4c1c4/image/content"}

Uploads

The following are all examples of valid content upload property values:

  • "file://image.png"

  • "upload://image.png"

  • "image.png"

  • {upload: "image.png"}

  • {source: "upload", filename: "image.png"}

Uploading files is a two-stage process. Firstly, the property is written. A good example is the Account image, which consists of a content facet that expects an image. The value of the property must be an object whose properties are the configured, uploaded facet names, with their being filenames with extensions matching the content-type accepted by the facet. For example, updating an Account image:Example

// PUT accounts/5516ee2634d8d93428169c0e/image 

Request: 
    {
        "content": "IMG_1399.JPG"        
    }
Response:
{
    "creator": "5516ee2634d8d93428169c0e",
    "facets": [{
        "creator": "5516ee2634d8d93428169c0e",
        "location": 4,
        "name": "thumbnail",
        "path": "/accounts/5516ee2634d8d93428169c0e/image/thumbnail",
        "state": 0
    }],
    "location": 4,
    "name": "content",
    "path": "/accounts/5516ee2634d8d93428169c0e/image/content",
    "state": 0,
    "uploads": [{
        "fields": [{
            "key": "x-amz-credential",
            "value": "AKIAJ3Z4AWM5JO6AILYQ/20150404/us-east-1/s3/aws4_request"
        }, {
            "key": "x-amz-date",
            "value": "20150404T041333Z"
        }, {
            "key": "x-amz-server-side-encryption",
            "value": "AES256"
        }, {
            "key": "x-amz-signature",
            "value": "e78ce424cafb6ce2accbaaf49e8a2a6cc7794c79b0f7c902e1e380caf9edfefc"
        }, {
            "key": "x-amz-algorithm",
            "value": "AWS4-HMAC-SHA256"
        }, {
            "key": "success_action_status",
            "value": "201"
        }, {
            "key": "content-type",
            "value": "image/jpeg"
        }, {
            "key": "key",
            "value": "5516ee1b34d8d934281699e3/436f6e746578742041636374/5516ee2634d8d93428169c0e.image/551f64ed3f2ab234373c8465.jpeg"
        }, {
            "key": "policy",
            "value": "eyJleHBpcmF0aW9uIjoiMjAxNS0wNC0xNFQxNDoxMzozMy40MzFaIiwiY29uZGl0aW9ucyI6W3siYnVja2V0IjoibWVkYWJsZS11cGxvYWRzLXNjYXJsZXQifSx7ImtleSI6IjU1MTZlZTFiMzRkOGQ5MzQyODE2OTllMy80MzZmNmU3NDY1Nzg3NDIwNDE2MzYzNzQvNTUxNmVlMjYzNGQ4ZDkzNDI4MTY5YzBlLmltYWdlLzU1MWY2NGVkM2YyYWIyMzQzNzNjODQ2NS5qcGVnIn0sWyJjb250ZW50LWxlbmd0aC1yYW5nZSIsMCw1MTIwMDAwXSx7ImNvbnRlbnQtdHlwZSI6ImltYWdlL2pwZWcifSx7IngtYW16LWFsZ29yaXRobSI6IkFXUzQtSE1BQy1TSEEyNTYifSx7IngtYW16LWNyZWRlbnRpYWwiOiJBS0lBSjNaNEFXTTVKTzZBSUxZUS8yMDE1MDQwNC91cy1lYXN0LTEvczMvYXdzNF9yZXF1ZXN0In0seyJ4LWFtei1kYXRlIjoiMjAxNTA0MDRUMDQxMzMzWiJ9LHsieC1hbXotc2VydmVyLXNpZGUtZW5jcnlwdGlvbiI6IkFFUzI1NiJ9LHsic3VjY2Vzc19hY3Rpb25fc3RhdHVzIjoiMjAxIn1dfQ=="
        }],            
        "location": 5,
        "maxFileSize": 5120000,
        "name": "content",
        "state": 0,
        "uploadKey": "file",
        "uploadMethod": "post",
        "uploadUrl": "https://medable-v2-uploads.s3.amazonaws.com"
    }]
}

The response contains new facets with a state of 0 (Pending).

For uploads, the next step is to scan the uploads array in the response and make an HTTP multipart/form-data POST for each entry in the array. For each entry:

  1. Build a form containing the fields defined in using the fields array in the order they appear.

  2. The last field in the form must be the file field corresponding to the file to be uploaded, and the field name must be equal to the uploadKey.

  3. The form action must be equal to the uploadUrl.

  4. The form method must be equal to the uploadMethod.

An html form for the above example might look like this:HTML

<form action="https://medable-v2-uploads.s3.amazonaws.com" method="post" enctype="multipart/form-data">
    <input type="hidden" name="x-amz-credential" value="AKIAJ3Z4AWM5JO6AILYQ/20150404/us-east-1/s3/aws4_request">
    <input type="hidden" name="x-amz-date" value="20150404T041333Z">
    <input type="hidden" name="x-amz-server-side-encryption" value="AES256">
    <input type="hidden" name="x-amz-signature" value="e78ce424cafb6ce2accbaaf49e8a2a6cc7794c79b0f7c902e1e380caf9edfefc">
    <input type="hidden" name="x-amz-algorithm" value="AWS4-HMAC-SHA256">
    <input type="hidden" name="success_action_status" value="201">
    <input type="hidden" name="key" value="5516ee1b34d8d934281699e3/436f6e746578742041636374/5516ee2634d8d93428169c0e.image/551f64ed3f2ab234373c8465.jpeg">
    <input type="hidden" name="policy" value="eyJleHBpcmF0aW9uIjoiMjAxNS0wNC0xNFQxNDoxMzozMy40MzFaIiwiY29uZGl0aW9ucyI6W3siYnVja2V0IjoibWVkYWJsZS11cGxvYWRzLXNjYXJsZXQifSx7ImtleSI6IjU1MTZlZTFiMzRkOGQ5MzQyODE2OTllMy80MzZmNmU3NDY1Nzg3NDIwNDE2MzYzNzQvNTUxNmVlMjYzNGQ4ZDkzNDI4MTY5YzBlLmltYWdlLzU1MWY2NGVkM2YyYWIyMzQzNzNjODQ2NS5qcGVnIn0sWyJjb250ZW50LWxlbmd0aC1yYW5nZSIsMCw1MTIwMDAwXSx7ImNvbnRlbnQtdHlwZSI6ImltYWdlL2pwZWcifSx7IngtYW16LWFsZ29yaXRobSI6IkFXUzQtSE1BQy1TSEEyNTYifSx7IngtYW16LWNyZWRlbnRpYWwiOiJBS0lBSjNaNEFXTTVKTzZBSUxZUS8yMDE1MDQwNC91cy1lYXN0LTEvczMvYXdzNF9yZXF1ZXN0In0seyJ4LWFtei1kYXRlIjoiMjAxNTA0MDRUMDQxMzMzWiJ9LHsieC1hbXotc2VydmVyLXNpZGUtZW5jcnlwdGlvbiI6IkFFUzI1NiJ9LHsic3VjY2Vzc19hY3Rpb25fc3RhdHVzIjoiMjAxIn1dfQ==">   
    <input type="file" name="file">
</form>

📘Note

If a File property has been updated, but the user logs out or cannot otherwise complete the upload within a period of time, the upload window may expire. Without having to reset the file property, facet uploads can be refreshed, to produce new upload information that can be used to initiate or continue an upload. To do so, update the file property directly with a refresh parameter. The json body must contain the facet names of the target uploads, and the response will contain an array of uploads that were refreshed.Example

// PUT accounts/5516ee2634d8d93428169c0e/image/refresh 

Request: 
    ["content"]        
Response:         
    {
        "data": [{
            "fields": [... /* updated form fields */ ],
            "filename": "image.jpg",
            "location": 5,
            "maxFileSize": 5120000,
            "name": "content",
            "state": 0,
            "uploadKey": "file",
            "uploadMethod": "post",
            "uploadUrl": "https://medable-v2-uploads.s3.amazonaws.com"
        }],
        "hasMore": false,
        "object": "list"
    }

Response codes from the AWS S3 (5) upload location are xml. See .

File
Amazon S3 Error Responses