|
@@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Http;
|
|
|
using TEAMModelOS.SDK.Extension.SnowFlake;
|
|
|
using TEAMModelOS.SDK.Context.Constant;
|
|
|
using TEAMModelOS.SDK.Helper.Common.JsonHelper;
|
|
|
+using TEAMModelOS.SDK.Helper.Security.ShaHash;
|
|
|
|
|
|
namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
|
|
|
{
|
|
@@ -32,16 +33,6 @@ namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
|
|
|
{
|
|
|
blobClient = BlobClientSingleton.getInstance(options.ConnectionString).GetBlobClient();
|
|
|
}
|
|
|
- else if (AzureBlobConfig.AZURE_CHINA.Equals(options.AzureTableDialect))
|
|
|
- {
|
|
|
- AESCrypt crypt = new AESCrypt();
|
|
|
- blobClient = BlobClientSingleton.getInstance(crypt.Decrypt(china, options.AzureTableDialect)).GetBlobClient();
|
|
|
- }
|
|
|
- else if (AzureBlobConfig.AZURE_GLOBAL.Equals(options.AzureTableDialect))
|
|
|
- {
|
|
|
- AESCrypt crypt = new AESCrypt();
|
|
|
- blobClient = BlobClientSingleton.getInstance(crypt.Decrypt(global, options.AzureTableDialect)).GetBlobClient();
|
|
|
- }
|
|
|
else { throw new BizException("请设置正确的AzureBlob文件存储配置信息!"); }
|
|
|
}
|
|
|
|
|
@@ -125,9 +116,11 @@ namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
|
|
|
}
|
|
|
}
|
|
|
await blockBlob.UploadFromStreamAsync(f.OpenReadStream());
|
|
|
+ string sha1= ShaHashHelper.GetSHA1(f.OpenReadStream());
|
|
|
AzureBlobModel model = new AzureBlobModel(f, _options.Container, groupName, name)
|
|
|
{
|
|
|
- BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + name
|
|
|
+ BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + name,
|
|
|
+ Sha1Code = sha1
|
|
|
};
|
|
|
list.Add(model);
|
|
|
}
|
|
@@ -180,6 +173,7 @@ namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
|
|
|
//var memi = provider.Mappings[fileext];
|
|
|
AzureBlobModel model = new AzureBlobModel(file, _options.Container, groupName, name , content_type)
|
|
|
{
|
|
|
+ Sha1Code=ShaHashHelper.GetSHA1(file.Create()),
|
|
|
BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + name
|
|
|
};
|
|
|
return model;
|
|
@@ -230,12 +224,14 @@ namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
|
|
|
blockBlob.Properties.ContentType = content_type;
|
|
|
}
|
|
|
|
|
|
- long length = System.Text.Encoding.Default.GetBytes(text).Length;
|
|
|
+
|
|
|
await blockBlob.UploadTextAsync(text);
|
|
|
+ byte[] bytes = System.Text.Encoding.Default.GetBytes(text);
|
|
|
//var provider = new FileExtensionContentTypeProvider();
|
|
|
//var memi = provider.Mappings[fileext];
|
|
|
- AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, name, content_type, length)
|
|
|
+ AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, name, content_type, bytes.Length)
|
|
|
{
|
|
|
+ Sha1Code = ShaHashHelper.GetSHA1(bytes),
|
|
|
BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + name
|
|
|
};
|
|
|
return model;
|
|
@@ -283,12 +279,14 @@ namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
|
|
|
blockBlob.Properties.ContentType = content_type;
|
|
|
}
|
|
|
string objStr = obj.ToJsonAbs();
|
|
|
- long length = System.Text.Encoding.Default.GetBytes(objStr).Length;
|
|
|
+
|
|
|
await blockBlob.UploadTextAsync(objStr);
|
|
|
//var provider = new FileExtensionContentTypeProvider();
|
|
|
//var memi = provider.Mappings[fileext];
|
|
|
- AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, name, content_type , length)
|
|
|
+ byte[] bytes = System.Text.Encoding.Default.GetBytes(objStr);
|
|
|
+ AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, name, content_type , bytes.Length)
|
|
|
{
|
|
|
+ Sha1Code = ShaHashHelper.GetSHA1(bytes),
|
|
|
BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + name
|
|
|
};
|
|
|
return model;
|
|
@@ -330,8 +328,10 @@ namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
|
|
|
}
|
|
|
}
|
|
|
await blockBlob.UploadFromStreamAsync(file.OpenReadStream());
|
|
|
+ string sha1 = ShaHashHelper.GetSHA1(file.OpenReadStream());
|
|
|
AzureBlobModel model = new AzureBlobModel(file, _options.Container, groupName, name)
|
|
|
- {
|
|
|
+ {
|
|
|
+ Sha1Code=sha1,
|
|
|
BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + name
|
|
|
};
|
|
|
return model;
|
|
@@ -379,6 +379,7 @@ namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
|
|
|
blockBlob.UploadFromStreamAsync(fileSteam).GetAwaiter().GetResult() ;
|
|
|
AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, fileName, folder, blockBlob.Properties.ContentType, fileSteam.Length)
|
|
|
{
|
|
|
+ Sha1Code = ShaHashHelper.GetSHA1(fileSteam),
|
|
|
BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + fileName
|
|
|
};
|
|
|
return model;
|
|
@@ -426,8 +427,10 @@ namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
|
|
|
}
|
|
|
}
|
|
|
await blockBlob.UploadFromStreamAsync(fileSteam);
|
|
|
- AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, fileName, folder, blockBlob.Properties.ContentType , fileSteam.Length)
|
|
|
+ string sha1 = ShaHashHelper.GetSHA1(fileSteam);
|
|
|
+ AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, fileName, folder, blockBlob.Properties.ContentType, fileSteam.Length)
|
|
|
{
|
|
|
+ Sha1Code = sha1,
|
|
|
BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + fileName
|
|
|
};
|
|
|
return model;
|
|
@@ -461,10 +464,12 @@ namespace TEAMModelOS.SDK.Module.AzureBlob.Implements
|
|
|
blockBlob.Properties.ContentType = content_type;
|
|
|
}
|
|
|
|
|
|
- long length = System.Text.Encoding.Default.GetBytes(text).Length;
|
|
|
+
|
|
|
await blockBlob.UploadTextAsync(text);
|
|
|
- AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, fileName, folder, blockBlob.Properties.ContentType, length)
|
|
|
+ byte[] bytes = System.Text.Encoding.Default.GetBytes(text);
|
|
|
+ AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, fileName, folder, blockBlob.Properties.ContentType, bytes.Length)
|
|
|
{
|
|
|
+ Sha1Code = ShaHashHelper.GetSHA1(bytes),
|
|
|
BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + fileName
|
|
|
};
|
|
|
return model;
|