Skip to content

Commit

Permalink
tweak file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Leask committed Jun 23, 2024
1 parent 6da067a commit 8425dee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/universal.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ const runtime = {
const url = utilitas.utilitas.assembleUrl(`/api/${path}`, query || {});
const token = options?.token || getToken();
const optAlert = { alert: options?.alert };
const textDecoder = new TextDecoder();
let body = null, contentType = null;
if (post?.constructor?.name === 'FormData') { body = post; }
else if (post) { body = JSON.stringify(post); contentType = _JSON; }
Expand All @@ -122,6 +121,7 @@ const runtime = {
if (options?.stream) {
switch (resp.status) {
case 200:
const textDecoder = new TextDecoder();
const reader = resp.body.getReader();
for await (const chunk of readChunks(reader)) {
await options.stream(textDecoder.decode(
Expand Down
5 changes: 4 additions & 1 deletion lib/webjam.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ const _init = async (options, callback) => {
await initSession(options.session, webjam.app);
const objRouter = await initRouter(options);
webjam.app.use(logger((str, args) => log(str.trim(), { time: true })));
webjam.app.use(bodyParser({ onerror: (err, ctx) => ctx.error = err }));
webjam.app.use(bodyParser({
jsonLimit: '100mb',
onerror: (err, ctx) => ctx.error = err
}));
webjam.app.use(json());
webjam.app.use(cors);
webjam.app.use(userAgent);
Expand Down

0 comments on commit 8425dee

Please sign in to comment.