Skip to main content

How to upload attachments via workflow or API


Users can write documents or images to the worksheet via workflow or API, if workflow, it supports URL only; if API, it supports two methods, both URL and Base64.

I. Upload Attachments via Workflow

The workflow triggered by Webhook receives external data to add to the worksheet or update the data in worksheets, and can upload attachments at the same time.

In the [Add Record] node or [Update Record] node of the workflow, the content passed in the attachment field must be a Json string consisting of one or more file addresses.

  • When uploading a file, the format is: url1 or ["url1"], for example: https://help.mingdao.com/logo.png or ["https://help.mingdao.com/logo.png"]

  • When uploading multiple files, it must be in the format of : ["url1", "url2"], for example: ["https://help.mingdao.com/logo.png","https://help.mingdao.com/img/introduction.mp4"].

Workflow Configuration

If you want to upload attachments via the [Add Record] node or [Update Record] node, select the text field as the file field.

For example, in the worksheet below, write the download link of the file to a text field [Download Link] first, and then through the workflow, automatically download and save it to the [File] field.

1. Configure the trigger node

3. Test

Write the download link into the field in the correct format. Just copy the following content directly (including []).

["https://help.mingdao.com/logo.png","https://help.mingdao.com/img/introduction.mp4"]

II. Upload Attachments via API

More details are in the figure below.

Parameter Introduction

{
controlId: //ID of the file control;
"value": //Links to external files. If there are multiple files, separate them with English commas;
"editType":0 //Data update type. 0-Overwrite existing file; 1-Add current file (Default: 0-Overwrite. This parameter may not be passed for new records, but is required for updated records);
"valueType":1//Ways to upload files. 1-external file link; 2-file stream byte-encoded base64 string (Default: 1. When it is 1, the external link is placed in the value parameter; when it is 2, the file stream base64 information is placed in the controlFiles parameter below);

"controlFiles":[{
"baseFile":"QABAAQQQAAG9nCwAAAA==", //base64 string (file stream byte encoding);
"fileName":"File name with suffix.xlsx" //File name with suffix;
}]
}

URL-Example

  • If uploading 1 file, the value assigned to the attachment field is "url1", for example, "https://help.mingdao.com/logo.png"

  • If uploading multiple files, the format is "url1,url2", for example, "https://help.mingdao.com/logo.png,https://help.mingdao.com/logo.png".

{
"appKey": "0a265**3a155de01",
"sign": "ZmFkZjExMmNlY***NDA4ZjI5N2YxZDEwMjlkZWNkOTRkNTg5NjBkYWQzOTYxYjgwMWM4ZDg5NzYwOGMxZjZmOA==",
"worksheetId": "61111f2eb94**ac37d7d6e",
"controls": [
{
"controlId": "61111f2eb94aac37d7d6f",
"value": "Test"
},
{
"controlId":"61111f2eb10caac37d7d71",
"value":"https://help.mingdao.com/logo.png",
"editType":0,
"valueType":1//Setting1
}
]
}

Base64 File Stream - Example

{
"appKey": "0a265**3a155de01",
"sign": "ZmFkZjExMmNlY***NDA4ZjI5N2YxZDEwMjlkZWNkOTRkNTg5NjBkYWQzOTYxYjgwMWM4ZDg5NzYwOGMxZjZmOA==",
"worksheetId": "61111f2eb94**ac37d7d6e",
"controls": [
{
"controlId": "61111f2eb94aac37d7d6f",
"value": "Test"
},
{
"controlId":"61111f2eb10caac37d7d71",
"editType":0,
"valueType":2,//Setting2
"controlFiles":[
{
"baseFile":"QABAAQQQAAG9nCwAAAA==",
"fileName":"File name with suffix.xlsx"
}]
}
]
}

Possible Timeout Issues

If you are using the interface for adding records in bulk and need to upload attachments at the same time, you may encounter the timeout problem because you need to wait until the attachments are uploaded before the successful status is returned.

Suggested Method

Write the URL of the attachment to a text field first to ensure that the basic data can be written quickly, and then upload the attachment through the workflow. See the example above for more details.

III. Comparison of Writing Attachments via API and Workflow

The main difference is the format of the file address.

  • The format in the workflow is: ["url1", "url2"].

  • The format in the API is: "url1,url2".

IV. Format of URL

  • The URL of the attachment must be accessible by the server of HAP.
  • Attachments can be downloaded and saved directly through the URL.
  • The end of the URL must be the extension.

Correct URL:


Have questions about this article? Send us feedback