Nat
Nat9mo ago

Get a image from an api

Hello, we download a image from an api. And we want to send this image in slack channel The script below get our image, and another script send the image on slack. These two scripts are in a flow. How to pass this image from a script to another script ? How we should process ? We tried to encode it in utf8 and then encore it in base64 to send it, but the image don't work. If we don't encode it in utf8, windmill throw an error saying it's bad unicode character for the database
const url = `https://creator.zoho.eu/api/v2.1/${account}/${application}/report/${report}/${recordId}/${field}/download`;

// REQUEST
const response = await fetch(url, {
method: "GET",
headers: { Authorization: "Zoho-oauthtoken " + token },
});

const blob = await response.blob();
const text = await blob.text();
const data = utf8.encode(text);

if (response.status >= 300) throw new Error(response.statusText);

return { success: true, data };
const url = `https://creator.zoho.eu/api/v2.1/${account}/${application}/report/${report}/${recordId}/${field}/download`;

// REQUEST
const response = await fetch(url, {
method: "GET",
headers: { Authorization: "Zoho-oauthtoken " + token },
});

const blob = await response.blob();
const text = await blob.text();
const data = utf8.encode(text);

if (response.status >= 300) throw new Error(response.statusText);

return { success: true, data };
1 Reply
Tiago Serafim
Tiago Serafim9mo ago
Since it's within a flow, I'd use the shared directory https://www.windmill.dev/docs/core_concepts/persistent_storage#shared-directory and if you want to pass on binary data between scripts, you should base64 encode them directly, see the example below the table https://www.windmill.dev/docs/core_concepts/rich_display_rendering#rich-display-formats
Rich Display Rendering | Windmill
The result renderer in Windmill supports rich display rendering, allowing you to customize the display format of your results. By leveraging specific formats, you can display images, files, tables, HTML, JSON, and more.
Persistent Storage | Windmill
Persistent storage refers to any method of storing data that remains intact and accessible even after a system is powered off, restarted, or experiences a crash.