This code works as expected …
let opts = {
parent: taskId,
file: fs.createReadStream(file),
name: `${fileName}`,
};
const attachment = await this.client.attachmentsApiInstance.createAttachmentForObject(opts);
But this code does not, it throws an error complaining about there being a bad request, or about ‘source.on not being a function’ - depending on if I try and pass a Blob or Buffer or Array
async attachImageToTask(taskId: string, imageBuffer: Blob, fileName: string): Promise<void> {
try {
let opts = {
parent: taskId,
file: imageBuffer,
name: `${fileName}`,
};
const attachment = await this.client.attachmentsApiInstance.createAttachmentForObject(opts);
The documentation for superagent implies that the file object can be a Blob or Buffer object on Node (I am running node 20) but I can’t fund any combination that works apart from fs.createReadStream() which can’t be used in a deployment environment like Vercel
Are there an examples of where the attachment API is called with something other than a file stream