We need to support storing .pptx resources to Squidex Asset, but it is not supported now. We got stuck here. We have paid support. Please help us to get this resolved.
Supported content type: This file extension is not supported. You can upload only: .jpeg | .jpg | .svg | .png | .mp3 | .doc | .docx | .xlsx | .ppt | .pdf | .mpeg | .xls
Squidex does not restrict the upload and mime types! If the mime type is now known it would just handle it as a normal binary file. Are you sure it is not the browser?
Hello, this is a restriction added internally using the Asset Scripts, specifically Create:
var allowedExtensions = [
"png",
"jpg",
"jpeg",
"svg",
"mpeg",
"doc",
"docx",
"xls",
"xlsx",
"pdf",
"ppt",
"mp3",
];
...
if (file extension not in list of allowed extensions) {
reject(
"This file extension is not supported. You can upload only: .jpeg | .jpg | .svg | .png | .mp3 | .doc | .docx | .xlsx | .ppt | .pdf | .mpeg | .xls"
);
}
So to support .pptx
you just need to add it to the array (and the rejection message).
That is exactly. file extension pptx is rejected.
Where I do I add this list? Do you mean Squidex need to support for a new release, or I can added to my configuration?
[slalFe] can you share your script here? thanks
Edit: For convenience and in case anyone has some feedback on our script:
var allowedExtensions = [
"png",
"jpg",
"jpeg",
"svg",
"mpeg",
"doc",
"docx",
"xls",
"xlsx",
"pdf",
"ppt",
"mp3",
];
var isAllowedExtension = false;
allowedExtensions.forEach((extension) => {
let fileName = ctx.command.fileName;
let lastIndex = fileName.lastIndexOf(".");
let myExtension = fileName.substring(lastIndex + 1);
if (myExtension == extension) {
isAllowedExtension = true;
return;
}
});
if (isAllowedExtension == false) {
reject(
"This file extension is not supported. You can upload only: .jpeg | .jpg | .svg | .png | .mp3 | .doc | .docx | .xlsx | .ppt | .pdf | .mpeg | .xls"
);
}
I would calculate the extension once and use an indexOf
thanks, I definitely should have spotted the repeated calculation of the extension!
Edit: Whenever we are using internal scripting I invariably point colleagues towards the documentation (https://docs.squidex.io/02-documentation/developer-guides/scripting)m however for assets it does not list the variables available as it does for content so it would be useful to get that added, or would maintaining that be a burden so a link to the code showing what’s available be easier? For example: https://github.com/Squidex/squidex/blob/master/backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/Scripting/ScriptingCompleterTests.cs#L80
If you are happy for me to add it in I can do so, will just create a duplicate table listing the asset specific variables (and make a note against existing table that it is for content scripts), however you may find my explanations lacking so I assume you would likely want to tweak before publishing anyway.
You can create a PR to the docs. Would appreciate it.
Have opened a PR for this: https://github.com/Squidex/squidex-docs2/pull/36
Feel free to amend it however you please!