summaryrefslogtreecommitdiff
path: root/std/mime/multipart.ts
diff options
context:
space:
mode:
authorMarcos Casagrande <marcoscvp90@gmail.com>2020-04-29 22:38:24 +0200
committerGitHub <noreply@github.com>2020-04-29 16:38:24 -0400
commit78e0ae643c8eb9817b3396cf07a263ce9f03fc4c (patch)
tree4838489b770ef478feb20fc81c31dded0ac1fae2 /std/mime/multipart.ts
parentd308e8d0c0469419517e05a36ba070633168dc67 (diff)
Fix MultipartReader for big files (#4865)
Diffstat (limited to 'std/mime/multipart.ts')
-rw-r--r--std/mime/multipart.ts10
1 files changed, 4 insertions, 6 deletions
diff --git a/std/mime/multipart.ts b/std/mime/multipart.ts
index b2ac8dcdd..6aadef938 100644
--- a/std/mime/multipart.ts
+++ b/std/mime/multipart.ts
@@ -308,7 +308,7 @@ export class MultipartReader {
}
// file
let formFile: FormFile | undefined;
- const n = await copy(p, buf);
+ const n = await copyN(p, buf, maxValueBytes);
const contentType = p.headers.get("content-type");
assert(contentType != null, "content-type must be set");
if (n > maxMemory) {
@@ -319,11 +319,8 @@ export class MultipartReader {
postfix: ext,
});
try {
- const size = await copyN(
- new MultiReader(buf, p),
- file,
- maxValueBytes
- );
+ const size = await copy(new MultiReader(buf, p), file);
+
file.close();
formFile = {
filename: p.fileName,
@@ -333,6 +330,7 @@ export class MultipartReader {
};
} catch (e) {
await remove(filepath);
+ throw e;
}
} else {
formFile = {