Use this guide when your app needs to upload a file first and then create a Terminal49 document.Documentation Index
Fetch the complete documentation index at: https://terminal49.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Any client stack can use this flow as long as it can make standard HTTP requests.
Overview
- Request a direct upload blob payload from Terminal49.
- Upload the file bytes to the returned
direct_upload.urlusing the returned headers. - Store the returned
signed_id. - Create a Terminal49 document with
attached_document = signed_id.
1) Request a direct upload blob
Endpoint:POST /rails/active_storage/direct_uploads
Send metadata for the file you want to upload:
Blob attributes explained
| Attribute | Type | What it is | How to create it |
|---|---|---|---|
filename | string | Original file name users see. | Use the file name from the uploaded file (for example 1462486 order.pdf). |
content_type | string | MIME type of the file. | Detect from file extension or file bytes (for PDF use application/pdf). |
byte_size | integer | Exact file size in bytes. | Read the file size from your filesystem or uploaded file object. |
checksum | string | Base64-encoded MD5 digest of the raw file bytes. | Compute MD5 on file bytes, then Base64-encode the binary MD5 result. |
Example ways to generate values
Get file size in bytes:Base64(MD5(file_bytes))):
2) Upload the file bytes to direct_upload.url
Use direct_upload.url to send the file, and send the direct_upload.headers object as request headers. Use whatever response is returned by that upload request.
3) Persist signed_id in your app
Save the signed_id with your internal record. You will use this value in the next step.
4) Create the document using attached_document
POST /documents