Skip to content

Commit

Permalink
Set hardcoded fileextension and mimetype when uploading a contentType. (
Browse files Browse the repository at this point in the history
  • Loading branch information
kavics committed Dec 10, 2023
1 parent 896249f commit 9c1b489
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Services.Core/Operations/UploadHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ public async Task<object> 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,
Expand All @@ -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))
Expand Down

0 comments on commit 9c1b489

Please sign in to comment.