Skip to content

Stream blob back to client rather than read into memory. #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
os: Visual Studio 2017

# Version format
version: 1.0.2.{build}
version: 1.0.3.{build}

cache:
- src\packages -> **\packages.config # preserve "packages" directory in the root of build folder but will reset it if packages.config is modified
Expand Down Expand Up @@ -35,7 +35,7 @@ deploy:
# MyGet Deployment for builds & releases
- provider: NuGet
server: https://www.myget.org/F/umbracofilesystemproviders-azure/api/v2/package
symbol_server: https://nuget.symbolsource.org/MyGet/umbracofilesystemproviders-azure
symbol_server: https://www.myget.org/F/umbracofilesystemproviders-azure/symbols/api/v2/package
api_key:
secure: fz0rUrt3B1HczUC1ZehwVsrFSWX9WZGDQoueDztLte9/+yQG+BBU7UrO+coE8lUf
artifact: /.*\.nupkg/
Expand Down
21 changes: 19 additions & 2 deletions src/UmbracoFileSystemProviders.Azure/AzureFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Our.Umbraco.FileSystemProviders.Azure
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using global::Umbraco.Core.Configuration;
using global::Umbraco.Core.IO;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
Expand Down Expand Up @@ -540,8 +541,19 @@ public DateTimeOffset GetLastModified(string path)
/// <returns>
/// The <see cref="string"/> representing the relative path.
/// </returns>
/// <remarks>
/// Umbraco 7.5.15 changed the way that relative paths are used for media upload.
/// This is the fixing issue where uploading file to replace creates new folder.
/// </remarks>
public string GetRelativePath(string fullPathOrUrl)
{
var lastSafeVersion = new Version(7, 5, 14);

if (UmbracoVersion.Current.CompareTo(lastSafeVersion) > 0)
{
return this.FixPath(fullPathOrUrl);
}

return this.ResolveUrl(fullPathOrUrl, true);
}

Expand Down Expand Up @@ -582,8 +594,7 @@ public Stream OpenFile(string path)
return null;
}

MemoryStream stream = new MemoryStream();
blockBlob.DownloadToStream(stream);
Stream stream = blockBlob.OpenRead();

if (stream.CanSeek)
{
Expand Down Expand Up @@ -702,6 +713,12 @@ private string FixPath(string path)
path = path.Substring(appVirtualPath.Length);
}

// Strip ~ before any others
if (path.StartsWith("~", StringComparison.InvariantCultureIgnoreCase))
{
path = path.Substring(1);
}

if (path.StartsWith(Delimiter))
{
path = path.Substring(1);
Expand Down