|
@@ -35,7 +35,7 @@ namespace TEAMModelOS.SDK.DI
|
|
}
|
|
}
|
|
|
|
|
|
public BlobServiceClient GetBlobServiceClient(string name = "Default")
|
|
public BlobServiceClient GetBlobServiceClient(string name = "Default")
|
|
- {
|
|
|
|
|
|
+ {
|
|
try
|
|
try
|
|
{
|
|
{
|
|
var options = _optionsMonitor.Get(name);
|
|
var options = _optionsMonitor.Get(name);
|
|
@@ -50,7 +50,7 @@ namespace TEAMModelOS.SDK.DI
|
|
}
|
|
}
|
|
|
|
|
|
public BlobContainerClient GetBlobContainerClient(string containerName, string name = "Default")
|
|
public BlobContainerClient GetBlobContainerClient(string containerName, string name = "Default")
|
|
- {
|
|
|
|
|
|
+ {
|
|
try
|
|
try
|
|
{
|
|
{
|
|
var options = _optionsMonitor.Get(name);
|
|
var options = _optionsMonitor.Get(name);
|
|
@@ -62,9 +62,9 @@ namespace TEAMModelOS.SDK.DI
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public BlobBatchClient GetBlobBatchClient(string name = "Default")
|
|
public BlobBatchClient GetBlobBatchClient(string name = "Default")
|
|
- {
|
|
|
|
|
|
+ {
|
|
try
|
|
try
|
|
{
|
|
{
|
|
var options = _optionsMonitor.Get(name);
|
|
var options = _optionsMonitor.Get(name);
|
|
@@ -85,7 +85,7 @@ namespace TEAMModelOS.SDK.DI
|
|
/// <param name="blobContainerSasPermissions">權限(可多選)Flags</param>
|
|
/// <param name="blobContainerSasPermissions">權限(可多選)Flags</param>
|
|
/// <param name="name"></param>
|
|
/// <param name="name"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- public (string uri ,string sas) GetBlobContainerSAS(string containerName, BlobContainerSasPermissions blobContainerSasPermissions, string name = "Default")
|
|
|
|
|
|
+ public (string uri, string sas) GetBlobContainerSAS(string containerName, BlobContainerSasPermissions blobContainerSasPermissions, string name = "Default")
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
@@ -154,11 +154,13 @@ namespace TEAMModelOS.SDK.DI
|
|
BlobContainerName = containerName
|
|
BlobContainerName = containerName
|
|
};
|
|
};
|
|
BlobContainerSasPermissions blobContainerSasPermissions = BlobContainerSasPermissions.Read;
|
|
BlobContainerSasPermissions blobContainerSasPermissions = BlobContainerSasPermissions.Read;
|
|
- if (isRead) {
|
|
|
|
|
|
+ if (isRead)
|
|
|
|
+ {
|
|
blobContainerSasPermissions = BlobContainerSasPermissions.Read;
|
|
blobContainerSasPermissions = BlobContainerSasPermissions.Read;
|
|
}
|
|
}
|
|
- else {
|
|
|
|
- blobContainerSasPermissions = BlobContainerSasPermissions.Delete| BlobContainerSasPermissions.Write | BlobContainerSasPermissions.Create | BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List;
|
|
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ blobContainerSasPermissions = BlobContainerSasPermissions.Delete | BlobContainerSasPermissions.Write | BlobContainerSasPermissions.Create | BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List;
|
|
}
|
|
}
|
|
blobSasBuilder.SetPermissions(blobContainerSasPermissions);
|
|
blobSasBuilder.SetPermissions(blobContainerSasPermissions);
|
|
var sskc = new StorageSharedKeyCredential(accountname, accountkey);
|
|
var sskc = new StorageSharedKeyCredential(accountname, accountkey);
|
|
@@ -170,12 +172,12 @@ namespace TEAMModelOS.SDK.DI
|
|
Path = containerName
|
|
Path = containerName
|
|
//Query = sasQueryParameters.ToString()
|
|
//Query = sasQueryParameters.ToString()
|
|
};
|
|
};
|
|
- return new BlobAuth { url = fullUri.Uri.ToString().Replace(fullUri.Uri.LocalPath,""), sas = sasQueryParameters.ToString(), timeout = time, name = containerName };
|
|
|
|
- // return (fullUri.Uri.ToString(), sasQueryParameters.ToString());
|
|
|
|
|
|
+ return new BlobAuth { url = fullUri.Uri.ToString().Replace(fullUri.Uri.LocalPath, ""), sas = sasQueryParameters.ToString(), timeout = time, name = containerName };
|
|
|
|
+ // return (fullUri.Uri.ToString(), sasQueryParameters.ToString());
|
|
}
|
|
}
|
|
catch
|
|
catch
|
|
{
|
|
{
|
|
- return null ;
|
|
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -232,7 +234,7 @@ namespace TEAMModelOS.SDK.DI
|
|
/// <param name="blobSasPermissions"></param>
|
|
/// <param name="blobSasPermissions"></param>
|
|
/// <param name="name"></param>
|
|
/// <param name="name"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- public BlobAuth GetBlobSasUriRead(string containerName, string blobName,string name = "Default")
|
|
|
|
|
|
+ public BlobAuth GetBlobSasUriRead(string containerName, string blobName, string name = "Default")
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
@@ -240,7 +242,7 @@ namespace TEAMModelOS.SDK.DI
|
|
var accountname = keys["AccountName"];
|
|
var accountname = keys["AccountName"];
|
|
var accountkey = keys["AccountKey"];
|
|
var accountkey = keys["AccountKey"];
|
|
var endpoint = keys["EndpointSuffix"];
|
|
var endpoint = keys["EndpointSuffix"];
|
|
- DateTimeOffset dateTime = DateTimeOffset.UtcNow.Add(new TimeSpan(365*99, 0, 15, 0));
|
|
|
|
|
|
+ DateTimeOffset dateTime = DateTimeOffset.UtcNow.Add(new TimeSpan(365 * 99, 0, 15, 0));
|
|
long time = dateTime.ToUnixTimeMilliseconds();
|
|
long time = dateTime.ToUnixTimeMilliseconds();
|
|
var blobSasBuilder = new BlobSasBuilder
|
|
var blobSasBuilder = new BlobSasBuilder
|
|
{
|
|
{
|
|
@@ -261,7 +263,7 @@ namespace TEAMModelOS.SDK.DI
|
|
Query = sasQueryParameters.ToString()
|
|
Query = sasQueryParameters.ToString()
|
|
};
|
|
};
|
|
return new BlobAuth { url = fullUri.Uri.ToString(), sas = sasQueryParameters.ToString(), timeout = time };
|
|
return new BlobAuth { url = fullUri.Uri.ToString(), sas = sasQueryParameters.ToString(), timeout = time };
|
|
- // return fullUri.Uri.ToString();
|
|
|
|
|
|
+ // return fullUri.Uri.ToString();
|
|
}
|
|
}
|
|
catch
|
|
catch
|
|
{
|
|
{
|
|
@@ -270,7 +272,7 @@ namespace TEAMModelOS.SDK.DI
|
|
}
|
|
}
|
|
|
|
|
|
public CloudTableClient GetCloudTableClient(string name = "Default")
|
|
public CloudTableClient GetCloudTableClient(string name = "Default")
|
|
- {
|
|
|
|
|
|
+ {
|
|
try
|
|
try
|
|
{
|
|
{
|
|
var options = _optionsMonitor.Get(name);
|
|
var options = _optionsMonitor.Get(name);
|
|
@@ -284,7 +286,7 @@ namespace TEAMModelOS.SDK.DI
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 可讓您管理儲存體帳戶中的所有佇列
|
|
/// 可讓您管理儲存體帳戶中的所有佇列
|
|
@@ -292,7 +294,7 @@ namespace TEAMModelOS.SDK.DI
|
|
/// <param name="name"></param>
|
|
/// <param name="name"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
public QueueServiceClient GetQueueServiceClient(string name = "Default")
|
|
public QueueServiceClient GetQueueServiceClient(string name = "Default")
|
|
- {
|
|
|
|
|
|
+ {
|
|
try
|
|
try
|
|
{
|
|
{
|
|
var options = _optionsMonitor.Get(name);
|
|
var options = _optionsMonitor.Get(name);
|
|
@@ -325,7 +327,7 @@ namespace TEAMModelOS.SDK.DI
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- public async Task<CloudTable> InitializeTable<T>()
|
|
|
|
|
|
+ public async Task<CloudTable> InitializeTable<T>()
|
|
{
|
|
{
|
|
string TableName = GetTableSpace<T>();
|
|
string TableName = GetTableSpace<T>();
|
|
CloudTable cloudTable = GetCloudTableClient().GetTableReference(TableName);
|
|
CloudTable cloudTable = GetCloudTableClient().GetTableReference(TableName);
|