//native
type Box = {
token: string;
};
/**
* Remove upload session
* Abort an upload session and discard all data uploaded.
This cannot be reversed.
The actual endpoint URL is returned by the [`Create upload session`](e://post-files-upload-sessions)
and [`Get upload session`](e://get-files-upload-sessions-id) endpoints.
*/
export async function main(auth: Box, upload_session_id: string) {
const url = new URL(
`https://api.box.com/2.0/files/upload_sessions/${upload_session_id}`,
);
const response = await fetch(url, {
method: "DELETE",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago