Skip to content

Commit ef62719

Browse files
committed
dbeaver/pro#7990 feat: add postForBlob helper function for using with export qm history servlets
1 parent 500cb7d commit ef62719

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

webapp/packages/core-utils/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,4 @@ export * from './bindFunctions.js';
8989
export * from './isNumber.js';
9090
export * from './getSubjectDifferences.js';
9191
export * from './downloadImage.js';
92+
export * from './postForBlob.js';
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* CloudBeaver - Cloud Database Manager
3+
* Copyright (C) 2020-2026 DBeaver Corp and others
4+
*
5+
* Licensed under the Apache License, Version 2.0.
6+
* you may not use this file except in compliance with the License.
7+
*/
8+
9+
export async function postForBlob(url: string, payload: unknown): Promise<Blob> {
10+
const response = await fetch(url, {
11+
method: 'POST',
12+
credentials: 'include',
13+
headers: { 'Content-Type': 'application/json' },
14+
body: JSON.stringify(payload),
15+
});
16+
17+
if (!response.ok) {
18+
throw new Error(`Request failed: ${response.status} ${response.statusText}`);
19+
}
20+
21+
return await response.blob();
22+
}

0 commit comments

Comments
 (0)