I am getting the following error when I am trying to upload a pdf file in Settings → Email templates → Attachments
The selected file „dummy.pdf“ has an unsupported format. Please use one of the following types: application/pdf, image/*.
I am getting the following error when I am trying to upload a pdf file in Settings → Email templates → Attachments
The selected file „dummy.pdf“ has an unsupported format. Please use one of the following types: application/pdf, image/*.
This is a Shopware Bug in platform/index.js at a9c8a171dec581c42697a0e9c5a845ab4949a863 · shopware/platform · GitHub
This issue can be fixed by changing the function to something like the following.(For developers we have to override the component)
const { Component } = Shopware;
Component.override('sw-media-upload-v2', {
methods: {
checkFileType(file) {
if (!this.fileAccept || this.fileAccept === '*/*') {
return true;
}
const fileTypes = this.fileAccept.split(',');
var FileTypeValid = false;
fileTypes.forEach(fileType => {
if(!FileTypeValid) {
const fileAcceptType = fileType.split('/');
const currentFileType = file?.type?.split('/') || file?.mimeType?.split('/');
console.log('fileAcceptType:'+fileAcceptType);
console.log('currentFileType:'+currentFileType);
if (fileAcceptType[0] !== currentFileType[0]) {
this.isCorrectFileType = false;
return;
}
if (fileAcceptType[1] === '*') {
this.isCorrectFileType = true;
FileTypeValid = true;
return;
}
this.isCorrectFileType = fileAcceptType[1] === currentFileType[1];
if (this.isCorrectFileType) {
FileTypeValid = true;
}
console.log('fileAcceptType-1:'+fileAcceptType[1]);
console.log('currentFileType-1:'+currentFileType[1]);
console.log('isCorrectFileType:'+this.isCorrectFileType);
}
});
if (this.isCorrectFileType) {
return true;
}
this.createNotificationError({
title: this.$tc('global.default.error'),
message: this.$tc('global.sw-media-upload-v2.notification.invalidFileType.message', 0, {
name: file.name || file.fileName,
supportedTypes: this.fileAccept,
}),
});
return false;
},
}
});