简体   繁体   English

通过 POST API 发送 ics blob

[英]Send ics blob through POST API

I would like to generate an ics file then transform it in blob to finally send it through an Zendesk API POST call我想生成一个 ics 文件,然后将其转换为 blob 以最终通过 Zendesk API POST 调用发送

The code编码

const blob = new Blob([icsContent], { type: "application/json" });
const uploadICSFile = await uploadZendeskFile('appointment.ics', blob);

axios POST axios 后

export async function uploadZendeskFile(filename: string, fileBlob: Blob): Promise<Upload> {
  return await axios.post(
    `https://${config.subdomain}.zendesk.com/api/v2/uploads.json?filename=${filename}`,
    fileBlob,
    {
      auth: {
        username: '*****',
        password: '*****'
      },
      headers: {
        'Content-Type': 'text/calendar',
      }
    }
  );
}

The answer:答案:

Typescript code: Typescript 代码:

    const blob = new Blob([icsContent], { type: "application/octet-stream" });
    const uploadICSFile = await uploadZendeskFile('appointment.ics', blob);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM