Skip to content

Commit

Permalink
Merge pull request #201 from Avanade/feature/updateFrameworkVersion
Browse files Browse the repository at this point in the history
Fix Azure Storage Adapter
  • Loading branch information
lucianareginalino authored Dec 1, 2023
2 parents 08b06be + 76767aa commit 785bb4c
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 48 deletions.
16 changes: 0 additions & 16 deletions Liquid.WebApi.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@ VisualStudioVersion = 17.0.31612.314
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Liquid.WebApi.Http", "src\Liquid.WebApi.Http\Liquid.WebApi.Http.csproj", "{25D05D84-4DFB-4F3D-92A2-B06DFA244BA4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Liquid.WebApi.Grpc", "src\Liquid.WebApi.Grpc\Liquid.WebApi.Grpc.csproj", "{7806419C-7191-4D7A-BD52-8E705553ABEB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Liquid.WebApi.Grpc.Tests", "test\Liquid.WebApi.Grpc.Tests\Liquid.WebApi.Grpc.Tests.csproj", "{3B8464A5-3795-464E-A3B2-D2851C9E38DC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{7B0BC311-679F-4D1F-BE49-DF3E49863792}"
ProjectSection(SolutionItems) = preProject
.github\workflows\liquid-ci-cd-http-extensions-crud.yml = .github\workflows\liquid-ci-cd-http-extensions-crud.yml
.github\workflows\liquid-ci-cd-http.yml = .github\workflows\liquid-ci-cd-http.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Grpc", "Grpc", "{15BED263-E56A-45B2-A647-7D44500383E1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Http", "Http", "{13C213E0-722A-4CD5-9209-21E12FDA0CA8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Liquid.WebApi.Http.Tests", "test\Liquid.WebApi.Http.Tests\Liquid.WebApi.Http.Tests.csproj", "{39DDC514-44CD-43BE-9E5B-C3B86665895E}"
Expand All @@ -35,14 +29,6 @@ Global
{25D05D84-4DFB-4F3D-92A2-B06DFA244BA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{25D05D84-4DFB-4F3D-92A2-B06DFA244BA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{25D05D84-4DFB-4F3D-92A2-B06DFA244BA4}.Release|Any CPU.Build.0 = Release|Any CPU
{7806419C-7191-4D7A-BD52-8E705553ABEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7806419C-7191-4D7A-BD52-8E705553ABEB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7806419C-7191-4D7A-BD52-8E705553ABEB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7806419C-7191-4D7A-BD52-8E705553ABEB}.Release|Any CPU.Build.0 = Release|Any CPU
{3B8464A5-3795-464E-A3B2-D2851C9E38DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B8464A5-3795-464E-A3B2-D2851C9E38DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B8464A5-3795-464E-A3B2-D2851C9E38DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B8464A5-3795-464E-A3B2-D2851C9E38DC}.Release|Any CPU.Build.0 = Release|Any CPU
{39DDC514-44CD-43BE-9E5B-C3B86665895E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{39DDC514-44CD-43BE-9E5B-C3B86665895E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{39DDC514-44CD-43BE-9E5B-C3B86665895E}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -61,8 +47,6 @@ Global
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{25D05D84-4DFB-4F3D-92A2-B06DFA244BA4} = {13C213E0-722A-4CD5-9209-21E12FDA0CA8}
{7806419C-7191-4D7A-BD52-8E705553ABEB} = {15BED263-E56A-45B2-A647-7D44500383E1}
{3B8464A5-3795-464E-A3B2-D2851C9E38DC} = {15BED263-E56A-45B2-A647-7D44500383E1}
{39DDC514-44CD-43BE-9E5B-C3B86665895E} = {13C213E0-722A-4CD5-9209-21E12FDA0CA8}
{52C452EC-7C53-4177-A0C5-8CCFC6C0D76F} = {13C213E0-722A-4CD5-9209-21E12FDA0CA8}
{B1629220-240B-4C02-80BE-655F093F86D8} = {13C213E0-722A-4CD5-9209-21E12FDA0CA8}
Expand Down
10 changes: 3 additions & 7 deletions src/Liquid.Adapter.AzureStorage/BlobClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,17 @@ public BlobClientFactory(IOptions<StorageSettings>? options)
}

///<inheritdoc/>
public List<BlobContainerClient> SetContainerClients()
public void SetContainerClients()
{
if(_options.Containers.Count == 0)
throw new ArgumentNullException(nameof(_options));

var clients = new List<BlobContainerClient>();
throw new ArgumentNullException(nameof(_options));

Check warning on line 30 in src/Liquid.Adapter.AzureStorage/BlobClientFactory.cs

View workflow job for this annotation

GitHub Actions / call-reusable-build-workflow / build

The parameter name '_options' is not declared in the argument list.

Check warning on line 30 in src/Liquid.Adapter.AzureStorage/BlobClientFactory.cs

View workflow job for this annotation

GitHub Actions / call-reusable-build-workflow / build

The parameter name '_options' is not declared in the argument list.

foreach(var container in _options.Containers)
{
var client = new BlobContainerClient(container.ConnectionString,container.ContainerName);

clients.Add(client);
_clients.Add(client);
}

return clients;
}

///<inheritdoc/>
Expand Down
10 changes: 5 additions & 5 deletions src/Liquid.Adapter.AzureStorage/BlobStorageAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public async Task<List<LiquidBlob>> GetAllBlobs(string containerName)

var item = new LiquidBlob
{
Blob = Encoding.UTF8.GetString(blob.Value.Content.ToArray()),
Blob = blob.Value.Content.ToArray(),
Name = blobItem.Name
};
results.Add(item);
Expand Down Expand Up @@ -98,7 +98,7 @@ public async Task<List<LiquidBlob>> ReadBlobsByTags(IDictionary<string, string>
var blob = await blockBlob.DownloadContentAsync();
var item = new LiquidBlob
{
Blob = Encoding.UTF8.GetString(blob.Value.Content.ToArray()),
Blob = blob.Value.Content.ToArray(),
Tags = blockBlob.GetTags().Value.Tags,
Name = blobItem.BlobName
};
Expand All @@ -108,7 +108,7 @@ public async Task<List<LiquidBlob>> ReadBlobsByTags(IDictionary<string, string>
}

///<inheritdoc/>
public async Task UploadBlob(string data, string name, string containerName, IDictionary<string, string>? tags = null)
public async Task UploadBlob(byte[] data, string name, string containerName, IDictionary<string, string>? tags = null)
{
var client = _factory.GetContainerClient(containerName);

Expand All @@ -118,7 +118,7 @@ public async Task UploadBlob(string data, string name, string containerName, IDi
{
Tags = tags
};
await blockBlob.UploadAsync(new MemoryStream(Encoding.UTF8.GetBytes(data)), options);
await blockBlob.UploadAsync(new MemoryStream(data), options);
}

///<inheritdoc/>
Expand All @@ -130,7 +130,7 @@ public async Task<LiquidBlob> ReadBlobsByName(string blobName, string containerN
var blob = await blockBlob.DownloadContentAsync();
var item = new LiquidBlob
{
Blob = Encoding.UTF8.GetString(blob.Value.Content.ToArray()),
Blob = blob.Value.Content.ToArray(),
Tags = blockBlob.GetTags().Value.Tags,
Name = blobName
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public static IServiceCollection AddLiquidAzureStorageAdapter(this IServiceColle
configuration.GetSection(configSection).Bind(settings);
});

services.AddTransient<IBlobClientFactory, BlobClientFactory>();
services.AddSingleton<IBlobClientFactory, BlobClientFactory>();

services.AddSingleton<ILiquidBlobStorageAdapter, BlobStorageAdapter>();
services.AddScoped<ILiquidBlobStorageAdapter, BlobStorageAdapter>();

return services;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Liquid.Adapter.AzureStorage/IBlobClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface IBlobClientFactory
/// for each container on the <see cref="StorageSettings"/> and
/// add to <see cref="Clients"/>.
/// </summary>
List<BlobContainerClient> SetContainerClients();
void SetContainerClients();

/// <summary>
/// Get an instance of <see cref="BlobContainerClient"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface ILiquidBlobStorageAdapter
/// <param name="name">Blob path.</param>
/// <param name="containerName">Blob container name.</param>
/// <param name="tags">Blob list of tags.</param>
Task UploadBlob(string data, string name, string containerName, IDictionary<string, string>? tags = null);
Task UploadBlob(byte[] data, string name, string containerName, IDictionary<string, string>? tags = null);

/// <summary>
/// Remove blob by id.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Company>Avanade Inc.</Company>
<Product>Liquid - Modern Application Framework</Product>
<Copyright>Avanade 2019</Copyright>
<Version>6.0.0-preview-20221201-01</Version>
<Version>6.0.0-preview-20221201-02</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsPackable>true</IsPackable>
<Description>
Expand Down
2 changes: 1 addition & 1 deletion src/Liquid.Adapter.AzureStorage/LiquidBlob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class LiquidBlob
/// <summary>
/// Conteúdo do blob.
/// </summary>
public string? Blob { get; set; }
public byte[]? Blob { get; set; }

/// <summary>
/// Nome do arquivo no Storage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<PackageId>Liquid.WebApi.Http.Extensions.Crud</PackageId>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Authors>Avanade Brazil</Authors>
Expand All @@ -22,7 +22,7 @@
<Copyright>Avanade 2019</Copyright>
<PackageProjectUrl>https://github.com/Avanade/Liquid.WebApi</PackageProjectUrl>
<PackageIcon>logo.png</PackageIcon>
<Version>6.0.0-preview-20230519-01</Version>
<Version>6.0.0-preview-20231130-01</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsPackable>true</IsPackable>
<DebugType>Full</DebugType>
Expand Down
4 changes: 2 additions & 2 deletions src/Liquid.WebApi.Http/Liquid.WebApi.Http.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<PackageId>Liquid.WebApi.Http</PackageId>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Authors>Avanade Brazil</Authors>
Expand All @@ -10,7 +10,7 @@
<Copyright>Avanade 2019</Copyright>
<PackageProjectUrl>https://github.com/Avanade/Liquid.WebApi</PackageProjectUrl>
<PackageIcon>logo.png</PackageIcon>
<Version>6.0.0-preview-20230517-01</Version>
<Version>6.0.0-preview-20231130-01</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsPackable>true</IsPackable>
<DebugType>Full</DebugType>
Expand Down
20 changes: 10 additions & 10 deletions src/Liquid.WebApi.Http/Settings/SwaggerSettings.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Liquid.Core.Attributes;
using Newtonsoft.Json;
using System.Text.Json.Serialization;
using System.Diagnostics.CodeAnalysis;

namespace Liquid.WebApi.Http.Settings
Expand All @@ -17,7 +17,7 @@ public class SwaggerSettings
/// <value>
/// The name.
/// </value>
[JsonProperty("name")]
[JsonPropertyName("name")]
public string Name { get; set; }

/// <summary>
Expand All @@ -26,7 +26,7 @@ public class SwaggerSettings
/// <value>
/// The host.
/// </value>
[JsonProperty("host")]
[JsonPropertyName("host")]
public string Host { get; set; }

/// <summary>
Expand All @@ -35,7 +35,7 @@ public class SwaggerSettings
/// <value>
/// Schemes.
/// </value>
[JsonProperty("schemes")]
[JsonPropertyName("schemes")]
public string[] Schemes { get; set; }

/// <summary>
Expand All @@ -44,7 +44,7 @@ public class SwaggerSettings
/// <value>
/// The title.
/// </value>
[JsonProperty("title")]
[JsonPropertyName("title")]
public string Title { get; set; }

/// <summary>
Expand All @@ -53,7 +53,7 @@ public class SwaggerSettings
/// <value>
/// The version.
/// </value>
[JsonProperty("version")]
[JsonPropertyName("version")]
public string Version { get; set; }

/// <summary>
Expand All @@ -62,7 +62,7 @@ public class SwaggerSettings
/// <value>
/// The description.
/// </value>
[JsonProperty("description")]
[JsonPropertyName("description")]
public string Description { get; set; }

/// <summary>
Expand All @@ -71,7 +71,7 @@ public class SwaggerSettings
/// <value>
/// The swagger endpoint.
/// </value>
[JsonProperty("endpoint")]
[JsonPropertyName("endpoint")]
public SwaggerEndpoint SwaggerEndpoint { get; set; }
}

Expand All @@ -87,7 +87,7 @@ public class SwaggerEndpoint
/// <value>
/// The URL.
/// </value>
[JsonProperty("url")]
[JsonPropertyName("url")]
public string Url { get; set; }

/// <summary>
Expand All @@ -96,7 +96,7 @@ public class SwaggerEndpoint
/// <value>
/// The name.
/// </value>
[JsonProperty("name")]
[JsonPropertyName("name")]
public string Name { get; set; }
}
}

0 comments on commit 785bb4c

Please sign in to comment.