From 1be933cac61a901f06c63e7b7edf5e74d87e5e7b Mon Sep 17 00:00:00 2001 From: Adrien Siffermann Date: Thu, 23 Jun 2016 08:53:00 +0200 Subject: [PATCH 1/2] Fix List issues --- src/GeekLearning.Storage.Azure/AzureStore.cs | 31 +++++++++++-------- src/GeekLearning.Storage.Azure/project.json | 2 +- .../FileSystemStore.cs | 23 ++++++++------ .../project.json | 2 +- src/GeekLearning.Storage/project.json | 2 +- 5 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/GeekLearning.Storage.Azure/AzureStore.cs b/src/GeekLearning.Storage.Azure/AzureStore.cs index 9ee1156..9b4ef33 100644 --- a/src/GeekLearning.Storage.Azure/AzureStore.cs +++ b/src/GeekLearning.Storage.Azure/AzureStore.cs @@ -1,13 +1,13 @@ -using Microsoft.WindowsAzure.Storage; -using Microsoft.WindowsAzure.Storage.Blob; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; - -namespace GeekLearning.Storage.Azure +namespace GeekLearning.Storage.Azure { + using Microsoft.WindowsAzure.Storage; + using Microsoft.WindowsAzure.Storage.Blob; + using System; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Threading.Tasks; + public class AzureStore : IStore { private string connectionString; @@ -15,7 +15,6 @@ public class AzureStore : IStore private Lazy client; private string containerName; - public AzureStore(string connectionString, string containerName) { if (string.IsNullOrWhiteSpace(connectionString)) @@ -54,13 +53,13 @@ private Task GetBlobReference(string path) if (uri.IsAbsoluteUri) { return this.client.Value.GetBlobReferenceFromServerAsync(uri); - } else + } + else { return this.container.Value.GetBlobReferenceFromServerAsync(path); } } - public async Task Read(string path) { return await this.ReadInMemory(path); @@ -78,7 +77,7 @@ public async Task ReadAllText(string path) using (var reader = new StreamReader(await blockBlob.OpenReadAsync(AccessCondition.GenerateEmptyCondition(), new BlobRequestOptions(), new OperationContext()))) { return await reader.ReadToEndAsync(); - }; + } } public async Task Save(Stream data, string path, string mimeType) @@ -103,6 +102,11 @@ public async Task Save(byte[] data, string path, string mimeType) public async Task List(string path) { + if (path.EndsWith("*")) + { + path = path.TrimEnd('*'); + } + BlobContinuationToken continuationToken = null; List results = new List(); do @@ -112,6 +116,7 @@ public async Task List(string path) results.AddRange(response.Results); } while (continuationToken != null); + return results.Select(blob => blob.Uri.ToString()).ToArray(); } diff --git a/src/GeekLearning.Storage.Azure/project.json b/src/GeekLearning.Storage.Azure/project.json index 3e7a40e..bdabf57 100644 --- a/src/GeekLearning.Storage.Azure/project.json +++ b/src/GeekLearning.Storage.Azure/project.json @@ -1,7 +1,7 @@ { "version": "0.0.1-*", "description": "GeekLearning.Storage.Azure Class Library", - "authors": [ "autex" ], + "authors": [ "Geek Learning", "Cyprien Autexier", "Adrien Siffermann" ], "packOptions": { "tags": [ ], "projectUrl": "", diff --git a/src/GeekLearning.Storage.FileSystem/FileSystemStore.cs b/src/GeekLearning.Storage.FileSystem/FileSystemStore.cs index cc44b90..6c386e0 100644 --- a/src/GeekLearning.Storage.FileSystem/FileSystemStore.cs +++ b/src/GeekLearning.Storage.FileSystem/FileSystemStore.cs @@ -1,21 +1,22 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; - -namespace GeekLearning.Storage.FileSystem +namespace GeekLearning.Storage.FileSystem { + using System; + using System.IO; + using System.Linq; + using System.Threading.Tasks; + public class FileSystemStore : IStore { private string absolutePath; + public FileSystemStore(string path, string appPath) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException("path"); } - if (System.IO.Path.IsPathRooted(path)) + + if (Path.IsPathRooted(path)) { this.absolutePath = path; } @@ -41,9 +42,10 @@ public Task List(string path) var directoryPath = Path.GetDirectoryName(Path.Combine(this.absolutePath, path)); if (!Directory.Exists(directoryPath)) { - return Task.FromResult(new string[0]); + return Task.FromResult(new string[0]); } - return Task.FromResult(Directory.GetFiles(directoryPath).Select(x => x.Replace(this.absolutePath, "")).ToArray()); + + return Task.FromResult(Directory.GetFiles(directoryPath).Select(x => x.Replace(this.absolutePath, "").Trim('/', '\\')).ToArray()); } public Task Read(string path) @@ -68,6 +70,7 @@ public async Task Save(Stream data, string path, string mimeType) { await data.CopyToAsync(file); } + return path; } diff --git a/src/GeekLearning.Storage.FileSystem/project.json b/src/GeekLearning.Storage.FileSystem/project.json index 26ba77c..6601f1c 100644 --- a/src/GeekLearning.Storage.FileSystem/project.json +++ b/src/GeekLearning.Storage.FileSystem/project.json @@ -1,7 +1,7 @@ { "version": "0.0.1-*", "description": "GeekLearning.Storage.FileSystem Class Library", - "authors": [ "autex" ], + "authors": [ "Geek Learning", "Cyprien Autexier", "Adrien Siffermann" ], "packOptions": { "tags": [ ], "projectUrl": "", diff --git a/src/GeekLearning.Storage/project.json b/src/GeekLearning.Storage/project.json index d4b8691..ce44156 100644 --- a/src/GeekLearning.Storage/project.json +++ b/src/GeekLearning.Storage/project.json @@ -1,7 +1,7 @@ { "version": "0.0.1-*", "description": "GeekLearning.Storage Class Library", - "authors": [ "autex" ], + "authors": [ "Geek Learning", "Cyprien Autexier", "Adrien Siffermann" ], "packOptions": { "tags": [ ], "projectUrl": "", From c8a2b0cf67053fed9b1c8f7d0a8dd11cf38994df Mon Sep 17 00:00:00 2001 From: Galo Date: Thu, 23 Jun 2016 08:57:29 +0200 Subject: [PATCH 2/2] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 6c99536..75f54f7 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ [![NuGet Version](http://img.shields.io/nuget/v/GeekLearning.Storage.FileSystem.svg?style=flat-square&label=nuget:%20filesystem)](https://www.nuget.org/packages/GeekLearning.Storage.FileSystem/) [![NuGet Version](http://img.shields.io/nuget/v/GeekLearning.Storage.Azure.svg?style=flat-square&label=nuget:%20azure%20 storage)](https://www.nuget.org/packages/GeekLearning.Storage.Azure/) [![Build Status](https://geeklearning.visualstudio.com/_apis/public/build/definitions/f841b266-7595-4d01-9ee1-4864cf65aa73/5/badge)](#) -# gl-dotnet-storage # gl-dotnet-storage