UNPKG

@translated/lara

Version:

Official Lara SDK for JavaScript and Node.js

29 lines (28 loc) 919 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BrowserS3Client = void 0; const client_1 = require("./client"); /** @internal */ class BrowserS3Client extends client_1.S3Client { async _upload(url, fields, file) { const formdata = new FormData(); for (const [key, value] of Object.entries(fields)) { formdata.append(key, value); } formdata.append("file", file); await fetch(url, { method: "POST", body: formdata }); } async download(url) { const response = await fetch(url); return response.blob(); } wrapMultiPartFile(file) { if (file instanceof File) return file; throw new TypeError(`Invalid file input in the browser. Expected an instance of File but received ${typeof file}.`); } } exports.BrowserS3Client = BrowserS3Client;