Open JGhignatti opened 5 years ago
I am facing the same issue with PSD files.
type is recognized by the machine that we are using. I faced the same issue with my macOS since i do not have old versions of MsOffice, yet my users when they ran the app in their windows machine, it recognized old versions and succeeded in uploading. i was succesful in uploading DOCX, XLSX
Hey ! I have the same issue with compressed files: every .zip/.tar/.7z files. As @JGhignatti explained: file type from FileUploader are not populated when uploading compressed file. I could not find a way to solve the problem using allowedMimeType. So here is my workaround:
First I define my uploader:
`this.uploader = new FileUploader({
url: '/api-upload',
isHTML5: true,
method: 'POST',
headers: [{ name: 'X-Requested-With', value: 'XMLHttpRequest' }],
filters: [
{
name: 'fileTypeAllowed',
// Alert when a file extension is not compressed
fn: function (item , options) {
let itemType = item.name.substring(item.name.lastIndexOf('.')+1, item.name.length) || item.name;
let fileTypesAllowed = ["7z","gz","zip","rar"];
if (!fileTypesAllowed.includes(itemType)) {
return this.queue.onWhenAddingFileFailed;
} else {
return this.queue;
}
}
}
]
});`
Then I am using the onWhenAddingFileFailed
method to alert user about the error:
` onAddingFileFailed() {
this.uploader.onWhenAddingFileFailed = (item: any, filter: any, options: any) => {
switch (filter.name) {
case 'fileTypeAllowed':
this.fileErrorDetail = {
file: item.name,
error: `File type not allowed`
}
break;
default: {
console.log('Invalid upload');
break;
}
}
};
}
`
This solution is working but it is really not a clean one. Don't you have another solution ?
@JGhignatti I had the same problem.
Go to Registry Editor (regedit) -> HKEY_CLASSES_ROOT -> .doc. Right click on .doc and select New -> String Value and enter Value name = "Content Type" and Value data = "application/msword".
Repeat the same steps also for HKEY_CLASSES_ROOT -> .docx, but in this case add Value data = "application/vnd.openxmlformats-officedocument.wordprocessingml.document".
@JGhignatti I had the same problem.
Go to Registry Editor (regedit) -> HKEY_CLASSES_ROOT -> .doc. Right click on .doc and select New -> String Value and enter Value name = "Content Type" and Value data = "application/msword".
Repeat the same steps also for HKEY_CLASSES_ROOT -> .docx, but in this case add Value data = "application/vnd.openxmlformats-officedocument.wordprocessingml.document".
thanks for this, this solved my problem.
Hello, I have the same issue with Google Chrome only. When I try to upload a specific Word document using Firefox the type is correct but in Google Chrome type is empty. The solution that you are suggesting is not solid on my application. The reason is that i can fix it on my PC but other users will still getting errors because the type it will be empty an empty string. Is there any solution to fix that?
Hi,
I'm having a problem on a specific case. I'm running:
"@angular/core": "^6.1.9"
Windows 10 Home, 64 bits and MacOS MojaveI have an uploader provider declared as
where `FILE_TYPES_DOCS is
and then on my component
When I run it on my Macbook, it works just fine for everything, but when I try to upload a
.doc
file from the Windows environment nothing happens. Debugging it I found a couple things.First is that the file uploaded hits the mim type check with empty type, so the check will always return false and nothing will happen.![documents-bug-1](https://user-images.githubusercontent.com/27514735/48950066-1d56ff00-ef21-11e8-9ced-59a7a6a5ac33.png)
Then I found this issue and thought that it was my problem (later to find that on my windows env I do have Office). This led me to change my uploader provider to
which didn't work as well.
Need help with that, why is the
type
only empty on my windows? Thx.