You will probably need to add a new file content provider in the usestaticfiles initializer. I think I may have an example, will dig it out in the morning
This code might not be perfect but I tested it and it seems to work.
The problem is that the mime type ".stp" isn't recognised by the server as being downloadable. We have to add in code to tell the server to download .stp files.
Add this in startup.cs > Configure method just above app.UseUmbraco():
var provider = new FileExtensionContentTypeProvider();
// Set the MIME type for .stp files
provider.Mappings[".stp"] = "application/octet-stream";
// Apply middleware only for .stp file requests
app.UseWhen(
context => context.Request.Path.HasValue && context.Request.Path.Value.EndsWith(".stp", StringComparison.OrdinalIgnoreCase),
appBuilder =>
{
appBuilder.UseStaticFiles(new StaticFileOptions
{
ContentTypeProvider = provider
});
}
);
How can I download stp file from my website?
Hi
I have a a-tag with download attribute and a file from media in href, which is an stp file and I can't download the file on my website.
I have the same code for websites in Umbraco version 7 and 8 - it works but now I'm using Umbraco version 12.
Are there any security settings in Umbraco 12 for download files?
Josefine
Hi,
You will probably need to add a new file content provider in the usestaticfiles initializer. I think I may have an example, will dig it out in the morning
Hi thanks for writing to me. An example would be great 😃
This code might not be perfect but I tested it and it seems to work.
The problem is that the mime type ".stp" isn't recognised by the server as being downloadable. We have to add in code to tell the server to download .stp files.
Add this in startup.cs > Configure method just above app.UseUmbraco():
Let me know if it works.
Thanks for your help. It works 😃
Glad it worked :D
is working on a reply...