Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit a667011

Browse files
author
Praburaj
committed
Adding more fallbacks for BufferingHelper temporary folder location
Fixes: #168
1 parent 543e0f4 commit a667011

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/Microsoft.AspNet.Http.Core/BufferingHelper.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System;
55
using System.IO;
6-
using Microsoft.AspNet.Http;
76
using Microsoft.AspNet.WebUtilities;
87

98
namespace Microsoft.AspNet.Http.Core
@@ -16,11 +15,9 @@ public static string TempDirectory
1615
{
1716
get
1817
{
19-
var temp = Environment.GetEnvironmentVariable("ASPNET_TEMP");
20-
if (string.IsNullOrEmpty(temp))
21-
{
22-
temp = Environment.GetEnvironmentVariable("TEMP");
23-
}
18+
// Look for folders in the following order.
19+
var temp = Environment.GetEnvironmentVariable("ASPNET_TEMP") ?? // ASPNET_TEMP - User set temporary location.
20+
Path.GetTempPath(); // Fall back.
2421

2522
if (!Directory.Exists(temp))
2623
{
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System.IO;
5+
using Xunit;
6+
7+
namespace Microsoft.AspNet.Http.Core.Tests
8+
{
9+
public class BufferingHelperTests
10+
{
11+
[Fact]
12+
public void GetTempDirectory_Returns_Valid_Location()
13+
{
14+
var tempDirectory = BufferingHelper.TempDirectory;
15+
Assert.NotNull(tempDirectory);
16+
Assert.True(Directory.Exists(tempDirectory));
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)