Skip to content

Commit e7e2a46

Browse files
authored
Merge pull request #8 from geeklearningio/master
Master
2 parents e895c16 + 2010a71 commit e7e2a46

File tree

6 files changed

+34
-27
lines changed

6 files changed

+34
-27
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
[![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/)
33
[![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/)
44
[![Build Status](https://geeklearning.visualstudio.com/_apis/public/build/definitions/f841b266-7595-4d01-9ee1-4864cf65aa73/5/badge)](#)
5-
# gl-dotnet-storage
65

76
# gl-dotnet-storage
87

src/GeekLearning.Storage.Azure/AzureStore.cs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
using Microsoft.WindowsAzure.Storage;
2-
using Microsoft.WindowsAzure.Storage.Blob;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.IO;
6-
using System.Linq;
7-
using System.Threading.Tasks;
8-
9-
namespace GeekLearning.Storage.Azure
1+
namespace GeekLearning.Storage.Azure
102
{
3+
using Microsoft.WindowsAzure.Storage;
4+
using Microsoft.WindowsAzure.Storage.Blob;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.IO;
8+
using System.Linq;
9+
using System.Threading.Tasks;
10+
1111
public class AzureStore : IStore
1212
{
1313
private string connectionString;
1414
private Lazy<CloudBlobContainer> container;
1515
private Lazy<CloudBlobClient> client;
1616
private string containerName;
1717

18-
1918
public AzureStore(string connectionString, string containerName)
2019
{
2120
if (string.IsNullOrWhiteSpace(connectionString))
@@ -54,13 +53,13 @@ private Task<ICloudBlob> GetBlobReference(string path)
5453
if (uri.IsAbsoluteUri)
5554
{
5655
return this.client.Value.GetBlobReferenceFromServerAsync(uri);
57-
} else
56+
}
57+
else
5858
{
5959
return this.container.Value.GetBlobReferenceFromServerAsync(path);
6060
}
6161
}
6262

63-
6463
public async Task<Stream> Read(string path)
6564
{
6665
return await this.ReadInMemory(path);
@@ -78,7 +77,7 @@ public async Task<string> ReadAllText(string path)
7877
using (var reader = new StreamReader(await blockBlob.OpenReadAsync(AccessCondition.GenerateEmptyCondition(), new BlobRequestOptions(), new OperationContext())))
7978
{
8079
return await reader.ReadToEndAsync();
81-
};
80+
}
8281
}
8382

8483
public async Task<string> Save(Stream data, string path, string mimeType)
@@ -103,6 +102,11 @@ public async Task<string> Save(byte[] data, string path, string mimeType)
103102

104103
public async Task<string[]> List(string path)
105104
{
105+
if (path.EndsWith("*"))
106+
{
107+
path = path.TrimEnd('*');
108+
}
109+
106110
BlobContinuationToken continuationToken = null;
107111
List<IListBlobItem> results = new List<IListBlobItem>();
108112
do
@@ -112,6 +116,7 @@ public async Task<string[]> List(string path)
112116
results.AddRange(response.Results);
113117
}
114118
while (continuationToken != null);
119+
115120
return results.Select(blob => blob.Uri.ToString()).ToArray();
116121
}
117122

src/GeekLearning.Storage.Azure/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"version": "0.0.1-*",
33
"description": "GeekLearning.Storage.Azure Class Library",
4-
"authors": [ "autex" ],
4+
"authors": [ "Geek Learning", "Cyprien Autexier", "Adrien Siffermann" ],
55
"packOptions": {
66
"tags": [ ],
77
"projectUrl": "",

src/GeekLearning.Storage.FileSystem/FileSystemStore.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Linq;
5-
using System.Threading.Tasks;
6-
7-
namespace GeekLearning.Storage.FileSystem
1+
namespace GeekLearning.Storage.FileSystem
82
{
3+
using System;
4+
using System.IO;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
98
public class FileSystemStore : IStore
109
{
1110
private string absolutePath;
11+
1212
public FileSystemStore(string path, string appPath)
1313
{
1414
if (string.IsNullOrEmpty(path))
1515
{
1616
throw new ArgumentNullException("path");
1717
}
18-
if (System.IO.Path.IsPathRooted(path))
18+
19+
if (Path.IsPathRooted(path))
1920
{
2021
this.absolutePath = path;
2122
}
@@ -41,9 +42,10 @@ public Task<string[]> List(string path)
4142
var directoryPath = Path.GetDirectoryName(Path.Combine(this.absolutePath, path));
4243
if (!Directory.Exists(directoryPath))
4344
{
44-
return Task.FromResult(new string[0]);
45+
return Task.FromResult(new string[0]);
4546
}
46-
return Task.FromResult(Directory.GetFiles(directoryPath).Select(x => x.Replace(this.absolutePath, "")).ToArray());
47+
48+
return Task.FromResult(Directory.GetFiles(directoryPath).Select(x => x.Replace(this.absolutePath, "").Trim('/', '\\')).ToArray());
4749
}
4850

4951
public Task<Stream> Read(string path)
@@ -68,6 +70,7 @@ public async Task<string> Save(Stream data, string path, string mimeType)
6870
{
6971
await data.CopyToAsync(file);
7072
}
73+
7174
return path;
7275
}
7376

src/GeekLearning.Storage.FileSystem/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"version": "0.0.1-*",
33
"description": "GeekLearning.Storage.FileSystem Class Library",
4-
"authors": [ "autex" ],
4+
"authors": [ "Geek Learning", "Cyprien Autexier", "Adrien Siffermann" ],
55
"packOptions": {
66
"tags": [ ],
77
"projectUrl": "",

src/GeekLearning.Storage/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"version": "0.0.1-*",
33
"description": "GeekLearning.Storage Class Library",
4-
"authors": [ "autex" ],
4+
"authors": [ "Geek Learning", "Cyprien Autexier", "Adrien Siffermann" ],
55
"packOptions": {
66
"tags": [ ],
77
"projectUrl": "",

0 commit comments

Comments
 (0)