feat: implement attachement preview
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -188,6 +188,25 @@ export function transceiveDownload<TRequest>(
|
||||
return { transaction: request.transaction };
|
||||
}
|
||||
|
||||
export async function transceiveBlob<TRequest>(operation: string, data: TRequest): Promise<Blob> {
|
||||
const request: ApiRequest<TRequest> = {
|
||||
version: API_VERSION,
|
||||
transaction: generateTransactionId(),
|
||||
operation,
|
||||
data,
|
||||
};
|
||||
let blob: Blob | null = null;
|
||||
await fetchWrapper.post(API_URL, request, {
|
||||
headers: { 'Accept': '*/*' },
|
||||
onStream: async (response: Response) => {
|
||||
blob = await response.blob();
|
||||
},
|
||||
});
|
||||
if (blob === null) throw new Error(`[${operation}] Empty preview response`);
|
||||
return blob;
|
||||
}
|
||||
|
||||
|
||||
function appendHiddenField(form: HTMLFormElement, name: string, value: string): void {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'hidden';
|
||||
|
||||
Reference in New Issue
Block a user