import type { Base64 } from "https://deno.land/x/windmill@v1.85.0/mod.ts";
import { decode } from "https://deno.land/std@0.152.0/encoding/base64.ts";
type Slack = {
token: string;
};
export async function main(
image: Base64,
channel: string,
slack: Slack,
imagename: string = "image.png",
) {
const formData = new FormData();
formData.append("token", slack.token);
formData.append("file", new File([decode(image)], imagename));
formData.append("channels", channel);
formData.append("filename", "image.png");
formData.append("filetype", imagename);
return await (
await fetch("https://slack.com/api/files.upload", {
method: "POST",
body: formData,
})
).json();
}
Submitted by admin 460 days ago
import type {
Base64
} from "https://deno.land/x/windmill@v1.85.0/mod.ts";
import { decode } from "https://deno.land/std@0.152.0/encoding/base64.ts";
type Slack = {
token: string;
};
export async function main(
image: Base64,
channel: string,
slack: Slack,
imagename: string = "image.png",
) {
const formData = new FormData();
formData.append("token", slack.token);
formData.append(
"file",
new File([decode(image)], imagename),
);
formData.append("channels", channel);
formData.append("filename", "image.png");
formData.append("filetype", imagename);
return await (await fetch("https://slack.com/api/files.upload", {
method: "POST",
body: formData,
})).json();
}
Submitted by admin 463 days ago
import type {
Base64,
Resource,
} from "https://deno.land/x/windmill@v1.85.0/mod.ts";
import { decode } from "https://deno.land/std@0.152.0/encoding/base64.ts";
export async function main(
image: Base64,
channel: string,
slack: Resource<"slack">,
imagename: string = "image.png",
) {
const formData = new FormData();
formData.append("token", slack.token);
formData.append(
"file",
new File([decode(image)], imagename),
);
formData.append("channels", channel);
formData.append("filename", "image.png");
formData.append("filetype", imagename);
return await (await fetch("https://slack.com/api/files.upload", {
method: "POST",
body: formData,
})).json();
}
Submitted by adam186 591 days ago
import type {
Base64,
Resource,
} from "https://deno.land/x/windmill@v1.70.1/mod.ts";
import { decode } from "https://deno.land/std@0.152.0/encoding/base64.ts";
export async function main(
image: Base64,
channel: string,
slack: Resource<"slack">,
imagename: string = "image.png",
) {
const formData = new FormData();
formData.append("token", slack.token);
formData.append(
"file",
new File([decode(image)], imagename),
);
formData.append("channels", channel);
formData.append("filename", "image.png");
formData.append("filetype", imagename);
return await (await fetch("https://slack.com/api/files.upload", {
method: "POST",
body: formData,
})).json();
}
Submitted by adam186 626 days ago
import type {
Base64,
Resource,
} from "https://deno.land/x/windmill@v1.30.0/mod.ts";
import { decode } from "https://deno.land/std@0.152.0/encoding/base64.ts";
export async function main(
image: Base64,
channel: string,
slack: Resource<"slack">,
imagename: string = "image.png",
) {
const formData = new FormData();
formData.append("token", slack.token);
formData.append(
"file",
new File([decode(image)], imagename),
);
formData.append("channels", channel);
formData.append("filename", "image.png");
formData.append("filetype", imagename);
return await (await fetch("https://slack.com/api/files.upload", {
method: "POST",
body: formData,
})).json();
}
Submitted by admin 822 days ago