Skip to content
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,5 @@ ModelManifest.xml
.paket/paket.exe

# FAKE - F# Make
.fake/
.fake/
/tests/GeekLearning.Integration.Test/appsettings.development.json
10 changes: 9 additions & 1 deletion GeekLearning.Storage.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "GeekLearning.Storage", "src\GeekLearning.Storage\GeekLearning.Storage.xproj", "{1F419C53-73C6-4460-B284-6A49AE41C596}"
EndProject
Expand All @@ -21,10 +21,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
.gitattributes = .gitattributes
.gitignore = .gitignore
GitVersion.yml = GitVersion.yml
global.json = global.json
LICENSE.md = LICENSE.md
README.md = README.md
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "GeekLearning.Storage.FileSystem.Server", "src\GeekLearning.Storage.FileSystem.Server\GeekLearning.Storage.FileSystem.Server.xproj", "{9D94CD6C-9451-449A-BED2-1C07D624A8E0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -51,6 +55,10 @@ Global
{590B21B0-2AFA-4329-82AD-EF180C50EB5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{590B21B0-2AFA-4329-82AD-EF180C50EB5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{590B21B0-2AFA-4329-82AD-EF180C50EB5C}.Release|Any CPU.Build.0 = Release|Any CPU
{9D94CD6C-9451-449A-BED2-1C07D624A8E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9D94CD6C-9451-449A-BED2-1C07D624A8E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9D94CD6C-9451-449A-BED2-1C07D624A8E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9D94CD6C-9451-449A-BED2-1C07D624A8E0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
9 changes: 9 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
branches:
dev(elop)?(ment)?$:
tag: alpha
features?[/-]:
tag: alpha.{BranchName}
releases?[/-]:
mode: ContinuousDeployment
hotfix(es)?[/-]:
mode: ContinuousDeployment
4 changes: 4 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"sdk" : { "version": "1.0.0-preview2-003121"},
"projects": [ "src", "tests", "samples" ]
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ public ValuesController(TemplatesStore templates)
public async Task<IEnumerable<string>> Get()
{

return new string[] { await templates.Store.ReadAllText("json.json"), "value2" };
return new string[] { await templates.Store.ReadAllTextAsync("json.json"), "value2" };
}

// GET api/values/5
[HttpGet("{id}")]
public string Get(int id)
[HttpGet("files")]
public async Task<IEnumerable<string>> Get(int id)
{
return "value";
var files = await templates.Store.ListAsync("");
return files.Select(x => x.PublicUrl);
}

// POST api/values
Expand Down
20 changes: 19 additions & 1 deletion samples/GeekLearning.Storage.BasicSample/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System.Security.Cryptography;

namespace GeekLearning.Storage.BasicSample
{
Expand All @@ -20,18 +21,33 @@ public Startup(IHostingEnvironment env)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
HostingEnvironement = env;
}

public IConfigurationRoot Configuration { get; }
public IHostingEnvironment HostingEnvironement { get; }

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();

services.AddStorage().AddAzureStorage().AddFileSystemStorage();
var rng = RandomNumberGenerator.Create();
byte[] signingKey = new byte[512];
rng.GetBytes(signingKey);

services.AddStorage()
.AddAzureStorage()
.AddFileSystemStorage(HostingEnvironement.ContentRootPath)
.AddFileSystemStorageServer(options=> {
options.SigningKey = signingKey;
options.BaseUri = new Uri("http://localhost:11149/");
});

services.Configure<StorageOptions>(Configuration.GetSection("Storage"));

services.AddScoped<TemplatesStore>();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand All @@ -40,6 +56,8 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();

app.UseFileSystemStorageServer();

app.UseMvc();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"value": "test"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"answer": "42"
}
11 changes: 11 additions & 0 deletions samples/GeekLearning.Storage.BasicSample/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,16 @@
"System": "Information",
"Microsoft": "Information"
}
},
"Storage": {
"Stores": {
"Templates": {
"Provider": "FileSystem",
"Parameters": {
"Path": "Templates",
"Access" : "Public"
}
}
}
}
}
37 changes: 18 additions & 19 deletions samples/GeekLearning.Storage.BasicSample/project.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-rc2-3002702",
"version": "1.0.0",
"type": "platform"
},
"Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
"Microsoft.Extensions.Options": "1.0.0-rc2-final",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"GeekLearning.Storage": "*",
"GeekLearning.Storage.Azure": "*",
"GeekLearning.Storage.FileSystem": "*"
"GeekLearning.Storage.FileSystem": "*",
"GeekLearning.Storage.FileSystem.Server": "*"
},

"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
}
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},

"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"dnxcore50",
"portable-net45+win8"
]
}
Expand All @@ -43,7 +40,9 @@
},

"runtimeOptions": {
"gcServer": true
"configProperties": {
"System.GC.Server": true
}
},

"publishOptions": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;

public static class GeekLearningAzureStorageExtensions
public static class AzureStorageExtensions
{

public static IServiceCollection AddAzureStorage(this IServiceCollection services)
Expand Down
4 changes: 2 additions & 2 deletions src/GeekLearning.Storage.Azure/AzureStorageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public string Name
}
}

public IStore BuildStore(StorageOptions.StorageStore storeOptions)
public IStore BuildStore(string storeName, IStorageStoreOptions storeOptions)
{
return new AzureStore(storeOptions.Parameters["ConnectionString"], storeOptions.Parameters["Container"]);
return new AzureStore(storeName, storeOptions.Parameters["ConnectionString"], storeOptions.Parameters["Container"]);
}
}
}
Loading