Attachment Picker

ID: attachment-picker

The attachment-picker field type renders a modal picker for an attachment.

Definition configuration:

{
    "type": "object",
    "_attachment": {
        "id": "default"
    }
}

Form configuration:

{
    "type": "attachment-picker"
}

Options

The following options may be specified for the control:

Option Type Default Description
picker.fileTypes array Array of allowable file extensions for upload (ex. `['png', 'jpg', pdf']`)
picker.maxFileSize integer Maximum allowed file size in bytes

Create a Document with an Attachment

Define a content model definition with some attachment-picker fields:

[object Object]

Preview content model:

[object Object]

Create a content instance:

[object Object]

The document will be created, with the 3 attachments. Note: if there is no attachment with an id of 'default' then there will not be a thumbnail displayed for the document.

[object Object]

Now the document's json looks like this:

{
    "title": "Sample doc",
    "attachment1": {
        "id": "default1",
        "name": "janeausten.jpg",
        "size": 89873,
        "contentType": "image/jpeg"
    },
    "attachment2": {
        "id": "default2",
        "name": "hemingway.jpg",
        "size": 22116,
        "contentType": "image/jpeg"
    },
    "attachment3": {
        "id": "default3",
        "name": "shakespeare.jpg",
        "size": 28573,
        "contentType": "image/jpeg"
    }
}

Replace an Attachment

Go to Edit Properties page and click Upload... button, choose a different file then save:

[object Object]

Now the attachment is replaced and the JSON is updated with the new attachment's information:

{
    "title": "Sample doc",
    "attachment1": {
        "id": "default1",
        "name": "janeausten.jpg",
        "size": 89873,
        "contentType": "image/jpeg"
    },
    "attachment2": {
        "id": "default2",
        "name": "hemingway.jpg",
        "size": 22116,
        "contentType": "image/jpeg"
    },
    "attachment3": {
        "id": "default3",
        "name": "carlsagan.jpg",
        "size": 20989,
        "contentType": "image/jpeg"
    }
}

Delete an Attachment

Go to Edit Properties page and click Clear button, then Save. The attachment is removed and the document icon. Note: if there is no attachment with an id of 'default' then there will not be a thumbnail displayed for the document.