1
1
import assert from 'node:assert/strict'
2
2
import { Buffer } from 'node:buffer'
3
+ import { File } from 'node:buffer'
3
4
import { createServer } from 'node:http'
4
5
import { describe , it } from 'node:test'
5
6
import { App } from '@tinyhttp/app'
@@ -353,7 +354,7 @@ describe('Multipart', () => {
353
354
it ( 'should parse multipart with files' , async ( ) => {
354
355
const fd = new FormData ( )
355
356
const file = new File ( [ 'hello world' ] , 'hello.txt' , { type : 'text/plain' } )
356
- fd . set ( 'file' , file )
357
+ fd . set ( 'file' , file as Blob )
357
358
const server = createServer ( async ( req : ReqWithBody < { file : [ File ] } > , res ) => {
358
359
await multipart ( ) ( req , res , ( err ) => err && console . log ( err ) )
359
360
@@ -380,8 +381,8 @@ describe('Multipart', () => {
380
381
new File ( [ 'bye world' ] , 'bye.txt' , { type : 'text/plain' } )
381
382
]
382
383
383
- fd . set ( 'file1' , files [ 0 ] )
384
- fd . set ( 'file2' , files [ 1 ] )
384
+ fd . set ( 'file1' , files [ 0 ] as Blob )
385
+ fd . set ( 'file2' , files [ 1 ] as Blob )
385
386
386
387
const server = createServer ( async ( req : ReqWithBody < { file1 : [ File ] ; file2 : [ File ] } > , res ) => {
387
388
await multipart ( ) ( req , res , ( err ) => err && console . log ( err ) )
@@ -405,7 +406,7 @@ describe('Multipart', () => {
405
406
it ( 'should support binary files' , async ( ) => {
406
407
const fd = new FormData ( )
407
408
const file = new File ( [ new Uint8Array ( [ 1 , 2 , 3 ] ) ] , 'blob.bin' , { type : 'application/octet-stream' } )
408
- fd . set ( 'file' , file )
409
+ fd . set ( 'file' , file as Blob )
409
410
410
411
const server = createServer ( async ( req : ReqWithBody < { file : [ File ] } > , res ) => {
411
412
await multipart ( ) ( req , res , ( err ) => err && console . log ( err ) )
@@ -495,8 +496,8 @@ describe('Limits', () => {
495
496
496
497
const fd = new FormData ( )
497
498
498
- fd . set ( 'file1' , new File ( [ 'hello world' ] , 'hello.txt' , { type : 'text/plain' } ) )
499
- fd . set ( 'file2' , new File ( [ 'bye world' ] , 'bye.txt' , { type : 'text/plain' } ) )
499
+ fd . set ( 'file1' , new File ( [ 'hello world' ] , 'hello.txt' , { type : 'text/plain' } ) as Blob )
500
+ fd . set ( 'file2' , new File ( [ 'bye world' ] , 'bye.txt' , { type : 'text/plain' } ) as Blob )
500
501
501
502
await makeFetch ( server ) ( '/' , {
502
503
body : fd ,
@@ -514,7 +515,7 @@ describe('Limits', () => {
514
515
515
516
const fd = new FormData ( )
516
517
517
- fd . set ( 'file' , new File ( [ 'hello world' ] , 'hello.txt' , { type : 'text/plain' } ) )
518
+ fd . set ( 'file' , new File ( [ 'hello world' ] , 'hello.txt' , { type : 'text/plain' } ) as Blob )
518
519
519
520
await makeFetch ( server ) ( '/' , {
520
521
body : fd ,
@@ -534,7 +535,7 @@ describe('Limits', () => {
534
535
535
536
const fd = new FormData ( )
536
537
537
- fd . set ( 'file' , new File ( [ 'hello world to everyone' ] , 'hello.txt' , { type : 'text/plain' } ) )
538
+ fd . set ( 'file' , new File ( [ 'hello world to everyone' ] , 'hello.txt' , { type : 'text/plain' } ) as Blob )
538
539
539
540
await makeFetch ( server ) ( '/' , {
540
541
body : fd ,
0 commit comments