Hey @DEKO - not sure if you still need help with this or not; I’ll send this anyway in case it helps someone else in the future. (Or maybe you’re still around
)
You had the right idea and I don’t blame you or the AIs for getting lost here - Baserow doesn’t have the best API documentation for file uploads.
Here’s what we’re going to set up:
And here’s a copy of the scenario if you want to just add it to your account:
1. Baserow - Watch Rows
This should already be working fine for you; just map the Baserow Table ID you’re watching for new rows.
2. Iterator
Here, map the field (array) that contains your files from the Watch module, for example:
3. Tinify - Compress an image
Select URL as the Image Source and map the url from the iterator:
4. Baserow - Make an API Call
Next, find the Baserow module “Make an API Call” and add it after Tinify:
We’ll use this module to upload files from Tinify to Baserow, “somewhere”.
Configure it like this:
- URL:
/api/user-files/upload-via-url/
- Method:
POST
- Body:
{ "url": "{{downloadUrl}}" } – replace {{downloadURL}} with the variable from Tinify
5. Array Aggregator
Add an array aggregator to collect all uploaded files into one bundle. Configure it like this:
- Source Module: Iterator
- Aggregated fields:
body (from last Baserow module)
6. Baserow - Make an API Call (last one!)
Last module we’ll add is another “make an API call” module for Baserow, and configure it like this:
-
URL: /api/database/rows/table/{{TABLE_ID}}/{{1.id}}/
Here, {{TABLE_ID}} is the ID of the table you’re updating rows in, and {{1.id}} is the ID of the row you’re updating.
Since you mentioned you’re wanting to update the same row that triggered the “Watch Rows” module, you can just map the “Row ID” variable from the first (trigger) Baserow module here.
-
Method: PATCH
-
Body:
{
"field_ID": [{{map(15.array; "body")}}]
}
What you’ll want to do here is:
-
Replace “ID” with your file upload field’s ID, you can get the ID from the column in Baserow:
So in my case above, “field_ID” would be “field_6351215”
-
Then, add square brackets [ ] and write the map() formula inside. You want to map “body” variable from the previous array aggregator
[{{map(15.array; "body")}}] << you can copy-paste this, you’ll just need to re-map the array variable to your own
It should look like this when finished:
Note that this will replace ALL files in the selected row’s “file upload” field, with the files from this scenario.
So if you’re only uploading images and stuff that Tiny can handle, you’ll be fine - but if you expect to upload e.g. SVG or PDF files in this field, it might be better to use a separate file upload column for Tiny’s compressed files. Call it “compressed” or something like that, and change the last module “field_ID” to that new column’s ID instead of the original one.
Cheers!
Sierra