0

Abort multipart upload

by
Published Oct 17, 2025

This endpoint aborts the multipart upload initiated with /create-multipart.

Script discourse Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Discourse = {
3
  apiKey: string;
4
  defaultHost: string;
5
  apiUsername: string;
6
};
7
/**
8
 * Abort multipart upload
9
 * This endpoint aborts the multipart upload initiated with /create-multipart.
10
 */
11
export async function main(
12
  auth: Discourse,
13
  body: { external_upload_identifier: string },
14
) {
15
  const url = new URL(`https://${auth.defaultHost}/uploads/abort-multipart.json`);
16

17
  const response = await fetch(url, {
18
    method: "POST",
19
    headers: {
20
      "Content-Type": "application/json",
21
      "API-KEY": auth.apiKey,
22
      "API-USERNAME": auth.apiUsername,
23
    },
24
    body: JSON.stringify(body),
25
  });
26
  if (!response.ok) {
27
    const text = await response.text();
28
    throw new Error(`${response.status} ${text}`);
29
  }
30
  return await response.json();
31
}
32