Search…
Upload files

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 File 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
1
// PUT accounts/5516ee2634d8d93428169c0e/image
2
3
Request:
4
{
5
"content": "IMG_1399.JPG"
6
}
7
Response:
8
{
9
"creator": "5516ee2634d8d93428169c0e",
10
"facets": [{
11
"creator": "5516ee2634d8d93428169c0e",
12
"location": 4,
13
"name": "thumbnail",
14
"path": "/accounts/5516ee2634d8d93428169c0e/image/thumbnail",
15
"state": 0
16
}],
17
"location": 4,
18
"name": "content",
19
"path": "/accounts/5516ee2634d8d93428169c0e/image/content",
20
"state": 0,
21
"uploads": [{
22
"fields": [{
23
"key": "x-amz-credential",
24
"value": "AKIAJ3Z4AWM5JO6AILYQ/20150404/us-east-1/s3/aws4_request"
25
}, {
26
"key": "x-amz-date",
27
"value": "20150404T041333Z"
28
}, {
29
"key": "x-amz-server-side-encryption",
30
"value": "AES256"
31
}, {
32
"key": "x-amz-signature",
33
"value": "e78ce424cafb6ce2accbaaf49e8a2a6cc7794c79b0f7c902e1e380caf9edfefc"
34
}, {
35
"key": "x-amz-algorithm",
36
"value": "AWS4-HMAC-SHA256"
37
}, {
38
"key": "success_action_status",
39
"value": "201"
40
}, {
41
"key": "content-type",
42
"value": "image/jpeg"
43
}, {
44
"key": "key",
45
"value": "5516ee1b34d8d934281699e3/436f6e746578742041636374/5516ee2634d8d93428169c0e.image/551f64ed3f2ab234373c8465.jpeg"
46
}, {
47
"key": "policy",
48
"value": "eyJleHBpcmF0aW9uIjoiMjAxNS0wNC0xNFQxNDoxMzozMy40MzFaIiwiY29uZGl0aW9ucyI6W3siYnVja2V0IjoibWVkYWJsZS11cGxvYWRzLXNjYXJsZXQifSx7ImtleSI6IjU1MTZlZTFiMzRkOGQ5MzQyODE2OTllMy80MzZmNmU3NDY1Nzg3NDIwNDE2MzYzNzQvNTUxNmVlMjYzNGQ4ZDkzNDI4MTY5YzBlLmltYWdlLzU1MWY2NGVkM2YyYWIyMzQzNzNjODQ2NS5qcGVnIn0sWyJjb250ZW50LWxlbmd0aC1yYW5nZSIsMCw1MTIwMDAwXSx7ImNvbnRlbnQtdHlwZSI6ImltYWdlL2pwZWcifSx7IngtYW16LWFsZ29yaXRobSI6IkFXUzQtSE1BQy1TSEEyNTYifSx7IngtYW16LWNyZWRlbnRpYWwiOiJBS0lBSjNaNEFXTTVKTzZBSUxZUS8yMDE1MDQwNC91cy1lYXN0LTEvczMvYXdzNF9yZXF1ZXN0In0seyJ4LWFtei1kYXRlIjoiMjAxNTA0MDRUMDQxMzMzWiJ9LHsieC1hbXotc2VydmVyLXNpZGUtZW5jcnlwdGlvbiI6IkFFUzI1NiJ9LHsic3VjY2Vzc19hY3Rpb25fc3RhdHVzIjoiMjAxIn1dfQ=="
49
}],
50
"location": 5,
51
"maxFileSize": 5120000,
52
"name": "content",
53
"state": 0,
54
"uploadKey": "file",
55
"uploadMethod": "post",
56
"uploadUrl": "https://medable-v2-uploads.s3.amazonaws.com"
57
}]
58
}
Copied!
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
1
<form action="https://medable-v2-uploads.s3.amazonaws.com" method="post" enctype="multipart/form-data">
2
<input type="hidden" name="x-amz-credential" value="AKIAJ3Z4AWM5JO6AILYQ/20150404/us-east-1/s3/aws4_request">
3
<input type="hidden" name="x-amz-date" value="20150404T041333Z">
4
<input type="hidden" name="x-amz-server-side-encryption" value="AES256">
5
<input type="hidden" name="x-amz-signature" value="e78ce424cafb6ce2accbaaf49e8a2a6cc7794c79b0f7c902e1e380caf9edfefc">
6
<input type="hidden" name="x-amz-algorithm" value="AWS4-HMAC-SHA256">
7
<input type="hidden" name="success_action_status" value="201">
8
<input type="hidden" name="key" value="5516ee1b34d8d934281699e3/436f6e746578742041636374/5516ee2634d8d93428169c0e.image/551f64ed3f2ab234373c8465.jpeg">
9
<input type="hidden" name="policy" value="eyJleHBpcmF0aW9uIjoiMjAxNS0wNC0xNFQxNDoxMzozMy40MzFaIiwiY29uZGl0aW9ucyI6W3siYnVja2V0IjoibWVkYWJsZS11cGxvYWRzLXNjYXJsZXQifSx7ImtleSI6IjU1MTZlZTFiMzRkOGQ5MzQyODE2OTllMy80MzZmNmU3NDY1Nzg3NDIwNDE2MzYzNzQvNTUxNmVlMjYzNGQ4ZDkzNDI4MTY5YzBlLmltYWdlLzU1MWY2NGVkM2YyYWIyMzQzNzNjODQ2NS5qcGVnIn0sWyJjb250ZW50LWxlbmd0aC1yYW5nZSIsMCw1MTIwMDAwXSx7ImNvbnRlbnQtdHlwZSI6ImltYWdlL2pwZWcifSx7IngtYW16LWFsZ29yaXRobSI6IkFXUzQtSE1BQy1TSEEyNTYifSx7IngtYW16LWNyZWRlbnRpYWwiOiJBS0lBSjNaNEFXTTVKTzZBSUxZUS8yMDE1MDQwNC91cy1lYXN0LTEvczMvYXdzNF9yZXF1ZXN0In0seyJ4LWFtei1kYXRlIjoiMjAxNTA0MDRUMDQxMzMzWiJ9LHsieC1hbXotc2VydmVyLXNpZGUtZW5jcnlwdGlvbiI6IkFFUzI1NiJ9LHsic3VjY2Vzc19hY3Rpb25fc3RhdHVzIjoiMjAxIn1dfQ==">
10
<input type="file" name="file">
11
</form>
Copied!

📘Note

Response codes from the AWS S3 (5) upload location are xml. See Amazon S3 Error Responses.
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
1
// PUT accounts/5516ee2634d8d93428169c0e/image/refresh
2
3
Request:
4
["content"]
5
Response:
6
{
7
"data": [{
8
"fields": [... /* updated form fields */ ],
9
"filename": "image.jpg",
10
"location": 5,
11
"maxFileSize": 5120000,
12
"name": "content",
13
"state": 0,
14
"uploadKey": "file",
15
"uploadMethod": "post",
16
"uploadUrl": "https://medable-v2-uploads.s3.amazonaws.com"
17
}],
18
"hasMore": false,
19
"object": "list"
20
}
Copied!
Last modified 1mo ago
Copy link