-
-
Notifications
You must be signed in to change notification settings - Fork 562
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
Update BlobStorage to use Azure.Storage.Blobs #1564
Merged
Merged
Changes from 12 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
107416d
Use Azure.Storage.Blobs Nuget packge to replace deprecated Microsoft.…
5d0eff1
Add missing PiranhaServiceBuilder extension method
17a8945
Remove unused Nuget package
465bc65
Add extension method check for success HTTP Status code
b2591fe
Optimize code
c923859
Add interface IInitializable to make Init() available in select places
0e46ed1
Use IInitializable and IInitializable.Init() to transpile Init calls
51f9122
Merge IStorageSession and IStorage
48d849f
Move Media.Init() call to App class
4ae3be6
Modify docs
0d64de5
Fix
25c9b10
Correct order of code
682a890
Reverse some of the breaking changes
69e6973
Remove duplicate empty line (make CodeFactor test pass)
dbba1b7
Remove unused `using` refs
1ad80e5
Undo changes to Piranha.Local.FileStorage
a7efc1c
Undo changes to IStorageSession
d9dcf2a
Undo changes
tedvanderveen daa90a3
Restore IStorageSession.cs
00a155f
Merge branch 'master' of https://github.com/tedvanderveen/piranha.core
a881b58
Revert changes to IMediaService
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,9 @@ | |
* | ||
*/ | ||
|
||
using System; | ||
using Azure.Core; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Azure.Storage.Auth; | ||
using Piranha; | ||
using Piranha.Azure; | ||
|
||
|
@@ -19,23 +20,28 @@ public static class BlobStorageExtensions | |
/// Adds the Azure BlobStorage module. | ||
/// </summary> | ||
/// <param name="serviceBuilder">The service builder</param> | ||
/// <param name="credentials">The auth credentials</param> | ||
/// <param name="containerName">The optional container name</param> | ||
/// <param name="credential"> | ||
/// The token credential used to sign requests. | ||
/// </param> | ||
/// <param name="blobContainerUri"> | ||
/// A <see cref="Uri"/> referencing the blob service. | ||
/// This is likely to be similar to "https://{account_name}.blob.core.windows.net". | ||
/// </param> | ||
/// <param name="naming">How uploaded media files should be named</param> | ||
/// <param name="scope">The optional service scope. Default is singleton</param> | ||
/// <returns>The service collection</returns> | ||
public static PiranhaServiceBuilder UseBlobStorage( | ||
this PiranhaServiceBuilder serviceBuilder, | ||
StorageCredentials credentials, | ||
string containerName = "uploads", | ||
Uri blobContainerUri, | ||
TokenCredential credential, | ||
BlobStorageNaming naming = BlobStorageNaming.UniqueFileNames, | ||
ServiceLifetime scope = ServiceLifetime.Singleton) | ||
{ | ||
serviceBuilder.Services.AddPiranhaBlobStorage(credentials, containerName, naming, scope); | ||
serviceBuilder.Services.AddPiranhaBlobStorage(blobContainerUri, credential, naming, scope); | ||
|
||
return serviceBuilder; | ||
} | ||
|
||
/// <summary> | ||
/// Adds the Azure BlobStorage module. | ||
/// </summary> | ||
|
@@ -61,22 +67,27 @@ public static PiranhaServiceBuilder UseBlobStorage( | |
/// Adds the services for the Azure BlobStorage service. | ||
/// </summary> | ||
/// <param name="services">The current service collection</param> | ||
/// <param name="credentials">The auth credentials</param> | ||
/// <param name="containerName">The optional container name</param> | ||
/// <param name="credential"> | ||
/// The token credential used to sign requests. | ||
/// </param> | ||
/// <param name="blobContainerUri"> | ||
/// A <see cref="Uri"/> referencing the blob service. | ||
/// This is likely to be similar to "https://{account_name}.blob.core.windows.net". | ||
/// </param> | ||
/// <param name="naming">How uploaded media files should be named</param> | ||
/// <param name="scope">The optional service scope. Default is singleton</param> | ||
/// <returns>The service collection</returns> | ||
public static IServiceCollection AddPiranhaBlobStorage( | ||
this IServiceCollection services, | ||
StorageCredentials credentials, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This constitutes the main breaking change when moving to the v.12 Azure SDK, as the |
||
string containerName = "uploads", | ||
Uri blobContainerUri, | ||
TokenCredential credential, | ||
BlobStorageNaming naming = BlobStorageNaming.UniqueFileNames, | ||
ServiceLifetime scope = ServiceLifetime.Singleton) | ||
{ | ||
App.Modules.Register<BlobStorageModule>(); | ||
|
||
services.Add(new ServiceDescriptor(typeof(IStorage), sp => | ||
new BlobStorage(credentials, containerName, naming), scope)); | ||
new BlobStorage(blobContainerUri, credential, naming), scope)); | ||
|
||
return services; | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is no longer checking that
media != null
, and inGetResourceName()
there is an access tomedia.Id
without checking for null values either. But I can fix this after merge.