pingdotgg / uploadthing

File uploads for modern web devs
https://uploadthing.com
MIT License
3.99k stars 294 forks source link

[Bug]: MIME Type Error on File Extensions #212

Closed btahir closed 1 year ago

btahir commented 1 year ago

What happened?

Trying to restrict files based on extension. I tried

'audio/mpeg': { maxFileSize: '16MB', maxFileCount: 1 },

but it gave me the following error

Screenshot 2023-07-07 at 6 47 59 PM

Similar errors for audio/mp3, audio/wav and video/mpeg etc

Additionally I also got a Type error for audio/mp3 or wav

Argument of type '{ 'audio/mp3': { maxFileSize: string; maxFileCount: number; }; video: { maxFileSize: "16MB"; maxFileCount: number; }; }' is not assignable to parameter of type 'FileRouterInputConfig'.
  Object literal may only specify known properties, and ''audio/mp3'' does not exist in type 'FileRouterInputConfig'.ts(2345)

What did you expect to happen?

Expected it to restrict uploaded files based on the MIME Types I listed.

Version

5.1.0

Reproduction Steps

No response

Reproduction Repository

No response

Relevant log output

No response

Code of Conduct

Mr0Bread commented 1 year ago

@btahir

For wav you can try to use MIME type audio/x-wav For mp3 audio/mpeg MIME Type should be used

Mr0Bread commented 1 year ago

Can't say anything specific regarding runtime issue you are having though

Mr0Bread commented 1 year ago

@markflorkowski There is definitely a bug. I opened a PR. Please take a look #215