From 9c1b489d9b05814f78bd9f75f69a54836aab3d3a Mon Sep 17 00:00:00 2001 From: kavics Date: Sun, 10 Dec 2023 09:14:37 +0100 Subject: [PATCH] Set hardcoded fileextension and mimetype when uploading a contentType. (#1998) --- 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))