import { WebClient } from "@slack/web-api";
import * as wmill from "windmill-client";
import { S3Object } from "windmill-client";
type Slack = {
token: string;
};
/**
* Send an image to channel
* Upload an image from Windmill object storage to a Slack channel.
*/
export async function main(
slack: Slack,
channel: string,
image: S3Object,
imagename: string = "image.png",
) {
const bytes = await wmill.loadS3File(image);
if (!bytes) {
throw new Error("Could not load the file from object storage");
}
const client = new WebClient(slack.token);
return await client.filesUploadV2({
channel_id: channel,
file: Buffer.from(bytes),
filename: imagename,
});
}
Submitted by hugo989 7 days ago