|
@@ -18,6 +18,8 @@ using TEAMModelOS.SDK.Helper.Security.ShaHash;
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
using TEAMModelOS.SDK.Context.Configuration;
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
+using Microsoft.Azure.Cosmos.Linq;
|
|
|
+using System.Reflection.Metadata;
|
|
|
|
|
|
namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
|
|
|
{
|
|
@@ -652,6 +654,49 @@ namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
|
|
|
return blob.Uri + sasBlobToken;
|
|
|
}
|
|
|
|
|
|
+ public List<BlobFileDto> GetBlobDirectory(string containerName, string blobName)
|
|
|
+ {
|
|
|
+ blobContainer = GetSASBoloClent(containerName);
|
|
|
+ CloudBlobDirectory cloudBlobDirectory = blobContainer.GetDirectoryReference(blobName);
|
|
|
+
|
|
|
+ BlobContinuationToken blobContinuationToken = new BlobContinuationToken();
|
|
|
+ //var blobResultSegment = cloudBlobDirectory.ListBlobsSegmentedAsync(blobContinuationToken).GetAwaiter().GetResult();
|
|
|
+ //IEnumerable<IListBlobItem> listBlobItems = blobResultSegment.Results;
|
|
|
+ List<BlobFileDto> blobProperties = new List<BlobFileDto>();
|
|
|
+ blobProperties = GetBlobProperties(blobProperties, cloudBlobDirectory);
|
|
|
+ return blobProperties;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<BlobFileDto> GetBlobProperties(List<BlobFileDto> blobProperties, CloudBlobDirectory blobDirectory)
|
|
|
+ {
|
|
|
+ BlobContinuationToken blobContinuationToken = new BlobContinuationToken();
|
|
|
+ var blobResultSegment1 = blobDirectory.ListBlobsSegmentedAsync(blobContinuationToken).GetAwaiter().GetResult();
|
|
|
+ IEnumerable<IListBlobItem> listBlobItems1 = blobResultSegment1.Results;
|
|
|
+ foreach (IListBlobItem listBlobItem in listBlobItems1)
|
|
|
+ {
|
|
|
+ if (listBlobItem.GetType() == typeof(CloudBlobDirectory))
|
|
|
+ {
|
|
|
+ CloudBlobDirectory cloudBlobDirectory = (CloudBlobDirectory)listBlobItem;
|
|
|
+ blobProperties = GetBlobProperties(blobProperties, cloudBlobDirectory);
|
|
|
+ }
|
|
|
+ else if (listBlobItem.GetType() == typeof(CloudBlockBlob))
|
|
|
+ {
|
|
|
+ CloudBlockBlob blobaa = (CloudBlockBlob)listBlobItem;
|
|
|
+ blobaa.FetchAttributesAsync();
|
|
|
+ BlobFileDto blobFileDto = new BlobFileDto();
|
|
|
+ blobFileDto.name = blobaa.Name;
|
|
|
+ blobFileDto.length = blobaa.Properties.Length;
|
|
|
+ blobFileDto.contentType = blobaa.Properties.ContentType;
|
|
|
+ blobFileDto.created = blobaa.Properties.Created != null ? blobaa.Properties.Created.Value.ToUnixTimeSeconds():0;//blobaa.Properties.Created.IsNull() ? 0 :
|
|
|
+ blobFileDto.lastModified = blobaa.Properties.LastModified != null? blobaa.Properties.LastModified.Value.ToUnixTimeSeconds():0;//blobaa.Properties.LastModified.IsNull()? 0:
|
|
|
+ blobFileDto.streamWriteSizeInBytes = blobaa.StreamWriteSizeInBytes;
|
|
|
+ blobFileDto.url = blobaa.Uri.AbsoluteUri;
|
|
|
+
|
|
|
+ blobProperties.Add(blobFileDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return blobProperties;
|
|
|
+ }
|
|
|
|
|
|
public string GetBlobSasUriRead(string containerName, string blobName, string policyName = null)
|
|
|
{
|