I have a single roster.csv file synced between my PC and Mac.
When uploading the file from windows, it doesn't return it's mime type in the file object, instead you get type:"". (Unless you have excel installed then it returns an excel specific type)
Examples of file types returned:
Linux/Mac returns type:"text/csv"Windows returns type:"" (empty)
Windows with Excel returns type:"application/vnd.ms-excel"
(Assuming the mime type would change with other programs as well)
This makes it nearly impossible to let my app reliably accept .csv files across platform.
So I was wondering for a solution, would it be possible to use something similar to this?
let type = currentFiles[i].type;
if(!type){
let textType = currentFiles[i].name.substring(currentFiles[i].name.lastIndexOf("."),
currentFiles[i].name.length); // based off https://stackoverflow.com/a/1203361/4105381, includes "." in file name
type = textType.length != currentFiles[i].name.length ? textType : undefined; // Returning undefined for readability, maybe return ""
}
// let fileTypeIndex: number = this.supportedFileTypes.indexOf(type);
The problem:
I have a single roster.csv file synced between my PC and Mac. When uploading the file from windows, it doesn't return it's mime type in the file object, instead you get type:"". (Unless you have excel installed then it returns an excel specific type)
Examples of file types returned: Linux/Mac returns
type:"text/csv"
Windows returnstype:""
(empty) Windows with Excel returnstype:"application/vnd.ms-excel"
(Assuming the mime type would change with other programs as well)This makes it nearly impossible to let my app reliably accept .csv files across platform.
So I was wondering for a solution, would it be possible to use something similar to this?
https://codepen.io/bryn/pen/mwPrmB/
Obviously we can't set "" but
[".csv", "text/csv"]
would workAnother cool solution would be to allow developers to write their own validation functions that they can parse to File Drop.
I'm still relatively new to the coding scene. Tell me if any of this sounds doable/reasonable