From d29085ce39d357a1b7e3828e6c2b0f09a48cc6e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Gyebrovszki?= Date: Sun, 10 Dec 2023 04:10:47 +0100 Subject: [PATCH] Set hardcoded fileextension and mimetype when uploading a contentType. --- src/Services.Core/Operations/UploadHandler.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Services.Core/Operations/UploadHandler.cs b/src/Services.Core/Operations/UploadHandler.cs index 1c6aa6dc0..8ce206d1c 100644 --- a/src/Services.Core/Operations/UploadHandler.cs +++ b/src/Services.Core/Operations/UploadHandler.cs @@ -325,6 +325,9 @@ public async Task ExecuteAsync(CancellationToken cancellationToken) // in case we just loaded this content SetPreviewGenerationPriority(uploadedContent); + var isContentType = uploadedContent.Path.StartsWith(Repository.ContentTypesFolderPath + "/", + StringComparison.OrdinalIgnoreCase); + if (FormFile != null) { await SaveFileToRepositoryAsync(uploadedContent, Content, chunkToken, @@ -333,7 +336,9 @@ await SaveFileToRepositoryAsync(uploadedContent, Content, chunkToken, else { // handle text data - var binData = new BinaryData { FileName = new BinaryFileName(uploadedContent.Name) }; + var binData = isContentType + ? new BinaryData {FileName = new BinaryFileName(uploadedContent.Name + ".ContentType"), ContentType = "text/xml"} + : new BinaryData {FileName = new BinaryFileName(uploadedContent.Name) }; // set content type only if we were unable to recognize it if (string.IsNullOrEmpty(binData.ContentType))