Skip to content

Commit 313b60a

Browse files
Load Balancing: Move temporary files and make them configurable to allow for media upload when load balancing the backoffice (#20717)
* make file upload location configurable * Update src/Umbraco.Core/Configuration/Models/HostingSettings.cs Co-authored-by: Copilot <[email protected]> * Fix default implementation --------- Co-authored-by: Copilot <[email protected]>
1 parent 4ee1d7b commit 313b60a

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

src/Umbraco.Core/Configuration/Models/HostingSettings.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ public class HostingSettings
2525
[DefaultValue(StaticLocalTempStorageLocation)]
2626
public LocalTempStorage LocalTempStorageLocation { get; set; } = Enum.Parse<LocalTempStorage>(StaticLocalTempStorageLocation);
2727

28+
/// <summary>
29+
/// Gets or sets a value for the location of temporary file uploads.
30+
/// </summary>
31+
/// <value>/umbraco/Data/TEMP/TemporaryFile if nothing is specified.</value>
32+
public string? TemporaryFileUploadLocation { get; set; }
33+
2834
/// <summary>
2935
/// Gets or sets a value indicating whether umbraco is running in [debug mode].
3036
/// </summary>

src/Umbraco.Core/Hosting/IHostingEnvironment.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ public interface IHostingEnvironment
4343
string LocalTempPath { get; }
4444

4545
/// <summary>
46-
/// The web application's hosted path
46+
/// Gets the location of temporary file uploads.
47+
/// </summary>
48+
public string TemporaryFileUploadPath => Path.Combine(LocalTempPath, "TemporaryFile");
49+
50+
/// <summary>
51+
/// The web application's hosted path.
4752
/// </summary>
4853
/// <remarks>
4954
/// In most cases this will return "/" but if the site is hosted in a virtual directory then this will return the

src/Umbraco.Infrastructure/Persistence/Repositories/Implement/LocalFileSystemTemporaryFileRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public LocalFileSystemTemporaryFileRepository(
2727

2828
private DirectoryInfo GetRootDirectory()
2929
{
30-
var path = Path.Combine(_hostingEnvironment.LocalTempPath, "TemporaryFile");
30+
var path = _hostingEnvironment.TemporaryFileUploadPath;
3131

3232
if (!Directory.Exists(path))
3333
{

src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ public string LocalTempPath
132132
}
133133
}
134134

135+
/// <inheritdoc />
136+
public string TemporaryFileUploadPath => _hostingSettings.CurrentValue.TemporaryFileUploadLocation
137+
?? Path.Combine(MapPathContentRoot(Core.Constants.SystemDirectories.TempData), "TemporaryFile");
138+
135139
/// <inheritdoc />
136140
public string MapPathWebRoot(string path) => _webHostEnvironment.MapPathWebRoot(path);
137141

0 commit comments

Comments
 (0)