+ 2

Html Input file can't recognize Autocad drawing files type?

I am trying to store .dwg files to firestore but input element with file type can't recognize the file type which is autocad and its extension. I want to set policy on files to upload limite extension . how could I handle this? [Note]: we can acces file type when we open a file through e.target.files[0].type. If I checked the extension through its name, some one can change a vedio extension to .dwg, uploading such is a big bug. Tried code : https://codedamn.com/playground/GMoNNsmmfCiJo_dynbppZ

27th Apr 2023, 12:04 PM
Yasin Rahnaward
Yasin Rahnaward - avatar
8 Réponses
+ 1
Browsers use mime type [media type] to detect files type and determine how to process URL, As its clearly mentioned in [ RFC 6838 ] there are 6 top-level types name which is registered to Mime type [text, audio, video, image, application,multipart-message]. There are other file type which is not registered to media type even some of them are not fit under currently top-level types name. ref[RFC 6838][4.2.7]. That's the reason why browser canot recognize the Autocad and corel Draw files type and set its type property value to an empty string. [solution]: we could determine file types base on its signature or in another word we could read the first bytes of its contents which represents the file type. Fortunately I found some threads on this issue in stackoverflow for code Implementation. links are 👇👇👇🤖🐧🐼
28th Apr 2023, 1:38 PM
Yasin Rahnaward
Yasin Rahnaward - avatar
+ 1
Yasin Rahnaward Well, if it's not programming related, surely this is not a good place to look for help. Post this question in Firestore help channel, or in general user help forums like SuperUser. You'll have way more chance to get useful help.
27th Apr 2023, 2:53 PM
Emerson Prado
Emerson Prado - avatar
0
Add in the question description a link to your code and the error you got
27th Apr 2023, 1:03 PM
Emerson Prado
Emerson Prado - avatar
0
Emerson Prado there is no error and sololearn can not access local storage to select a file. When try to select a .dwg file through file input , it cannot recognize the file type and file type value is an empty string where for an video or image the file type property value is video/mp4 or image/png and so ...
27th Apr 2023, 1:19 PM
Yasin Rahnaward
Yasin Rahnaward - avatar
0
Emerson Prado <input type="file"/> html input tag is out of programming 🤖🤵? For clarifying: Sololearn doesn't have the ability to select a file, code bit will not help here so the problem is with input html tag that can't recognize some file extensions we could see it with simple clg in browser no need to firebase. I hoped that may some one could help me. But thanks for your guidance🐼😊، I searched alot
27th Apr 2023, 3:27 PM
Yasin Rahnaward
Yasin Rahnaward - avatar
27th Apr 2023, 6:40 PM
Yasin Rahnaward
Yasin Rahnaward - avatar
0
One key advice for getting help, not only here, is to always be clear on what you're trying to do. The previous answer made me think there was no code involved. So there's indeed code. Always include a link to it. Even if it doesn't work in SoloLearn, at the very minimum, we have to see it. I'll check it. I'm clueless about firestore, but let's see if reading the code gets me somewhere.
28th Apr 2023, 2:49 AM
Emerson Prado
Emerson Prado - avatar