Edits history of script submission #22429 for ' Get File Public URL (hubspot)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    import { Client } from "@hubspot/api-client@^8.1.0";
    
    type Hubspot = {
      token: string;
    };
    export async function main(
      auth: Hubspot,
      file_id: string,
      size?: "" | "thumb" | "icon" | "medium" | "preview",
      expiration_seconds?: number,
      upscale?: boolean,
    ) {
      const client = new Client({
        accessToken: auth.token,
      });
    
      try {
        return await client.files.filesApi.getSignedUrl(
          file_id,
          size || undefined,
          expiration_seconds || undefined,
          upscale || undefined,
        );
      } catch (e) {
        throw Error(`
          ${e.code}\n
          Message: ${e.body.message || e.body}\n
        `);
      }
    }
    

    Submitted by hugo989 7 days ago