Skip to content

Conversation

@nikolajlauridsen
Copy link
Contributor

@nikolajlauridsen nikolajlauridsen commented Nov 3, 2025

Problem

Previously, temporary files managed through /umbraco/management/api/v1/temporary-file were stored in _hostingEnvironment.LocalTempPath.

In load-balanced setups where Umbraco:CMS:Hosting:LocalTempStorageLocation is configured to "EnvironmentTemp", Umbraco ensures _hostingEnvironment.LocalTempPath is unique per instance. This is critical for Azure deployments where the Umbraco folder is shared between instances.

However, this isolation creates a problem for temporary uploaded files, which need to be accessible across all instances. Consider this scenario:

  1. File is uploaded to /umbraco/management/api/v1/temporary-file on server A
  2. Request to create media using that file is routed to server B
  3. Server B cannot access the file created by server A

Solution

Temporary files now always save to umbraco/Data/TEMP/TemporaryFile/ regardless of the Umbraco:CMS:Hosting:LocalTempStorageLocation setting.

For Azure: This works out of the box since the umbraco folder is shared between instances when scaling out.

For other setups (e.g., Docker): A new configuration option Umbraco:CMS:Hosting:TemporaryFileUploadLocation allows you to specify a custom path (such as a shared drive or volume).

Alternative approach: For advanced scenarios, you can implement a custom ITemporaryFileRepository using external storage like Azure Blob Storage (better suited for a package than core).

Testing

  • Configure Umbraco:CMS:Hosting:LocalTempStorageLocation to "EnvironmentTemp" and verify files uploaded via /umbraco/management/api/v1/temporary-file are saved to umbraco/Data/TEMP/TemporaryFile/
  • Configure Umbraco:CMS:Hosting:TemporaryFileUploadLocation to a custom location and verify files are uploaded to that folder
  • For both configurations, verify media uploads work correctly

@nikolajlauridsen nikolajlauridsen marked this pull request as ready for review November 3, 2025 11:57
Copilot AI review requested due to automatic review settings November 3, 2025 11:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a configurable location for temporary file uploads in Umbraco CMS. Previously, temporary file uploads were hardcoded to LocalTempPath + "/TemporaryFile", and this change allows users to customize this location via configuration settings.

  • Adds TemporaryFileUploadLocation configuration property to HostingSettings
  • Introduces TemporaryFileUploadPath property to IHostingEnvironment with a default implementation
  • Refactors LocalFileSystemTemporaryFileRepository to use the new configurable path

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/Umbraco.Core/Configuration/Models/HostingSettings.cs Adds new TemporaryFileUploadLocation configuration property
src/Umbraco.Core/Hosting/IHostingEnvironment.cs Adds TemporaryFileUploadPath property with default implementation returning LocalTempPath
src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs Implements TemporaryFileUploadPath using configuration with fallback to default path
src/Umbraco.Infrastructure/Persistence/Repositories/Implement/LocalFileSystemTemporaryFileRepository.cs Refactored to use TemporaryFileUploadPath instead of inline path construction

nikolajlauridsen and others added 3 commits November 3, 2025 13:27
…ion-lb-friendly-and-configurable' into v17/hotfix/make-fileupload-location-lb-friendly-and-configurable
Copy link
Contributor

@AndyButland AndyButland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and works as expected. I've tested the outlined scenarios and with a default and custom folder I see the temporary files created in the expected place, and media uploads work with both configurations.

@AndyButland AndyButland merged commit 313b60a into release/17.0 Nov 3, 2025
22 checks passed
@AndyButland AndyButland deleted the v17/hotfix/make-fileupload-location-lb-friendly-and-configurable branch November 3, 2025 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants