@@ -286,6 +286,35 @@ describe('testing GET object', () => {
286286 * multipart upload
287287 */
288288describe ( 'testing POST object via multipart upload' , ( ) => {
289+ test ( 'preserve charset in content-type for non-zero byte files' , async ( ) => {
290+ const form = new FormData ( )
291+ form . append ( 'file' , fs . createReadStream ( `./src/test/assets/sadcat.jpg` ) )
292+
293+ const headers = Object . assign ( { } , form . getHeaders ( ) , {
294+ authorization : `Bearer ${ process . env . AUTHENTICATED_KEY } ` ,
295+ 'x-upsert' : 'true' ,
296+ 'content-type' : 'text/markdown; charset=UTF-8' ,
297+ } )
298+
299+ const response = await appInstance . inject ( {
300+ method : 'POST' ,
301+ url : '/object/bucket2/charset-test.md' ,
302+ headers,
303+ payload : form ,
304+ } )
305+
306+ expect ( response . statusCode ) . toBe ( 200 )
307+
308+ const client = await getSuperuserPostgrestClient ( )
309+ const object = await client
310+ . table ( 'objects' )
311+ . select ( '*' )
312+ . where ( 'name' , 'charset-test.md' )
313+ . first ( )
314+
315+ expect ( object ) . not . toBeFalsy ( )
316+ expect ( object ?. metadata ?. mimetype ) . toBe ( 'text/markdown; charset=UTF-8' )
317+ } )
289318 test ( 'check if RLS policies are respected: authenticated user is able to upload authenticated resource' , async ( ) => {
290319 const form = new FormData ( )
291320 form . append ( 'file' , fs . createReadStream ( `./src/test/assets/sadcat.jpg` ) )
@@ -807,7 +836,9 @@ describe('testing POST object via multipart upload', () => {
807836 . first ( )
808837
809838 expect ( objectResponse ) . toBe ( undefined )
839+
810840 } )
841+
811842} )
812843
813844/*
0 commit comments