问题描述
我每天通过sFTP接收到ADLS第2代存储帐户的文件.我需要通过检查存储在ADLS gen2中的文件的MD5来验证文件.
我尝试使用BLOB API,目前它不支持ADLS gen2.如果该文件存储在Blob存储中,则可以从blob属性获取Content MD5.
有人可以帮助从ADLS第2代获取内容MD5吗?
到目前为止,您所知道的不支持Blob api,但是您可以看看 Data Lake Storage Gen2 rest api
->
如果您不知道如何生成sas令牌,则可以导航至azure门户->您的存储帐户,然后按照以下屏幕截图进行操作:
I receive daily files through sFTP to ADLS gen 2 storage account. I need to verify the file by checking the MD5 of the file stored in ADLS gen2.
I tried using the BLOB API , currently its not supporting ADLS gen2. I was able to get Content MD5 from blob properties if the file is stored in Blob storage.
Can someone help how to get the content MD5 from ADLS gen 2?
As of now, Blob api is not supported as you know, but you can take a look at Data Lake Storage Gen2 rest api
-> Path - Get Properties, which can be used to fetch properties of files stored in ADLS Gen2.
Here is a sample code(Note that I use the sas token appended to the api url):
using System;
using System.Net;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
string sasToken = "?sv=2018-03-28&ss=b&srt=sco&sp=rwdl&st=2019-04-15T08%3A07%3A49Z&se=2019-04-16T08%3A07%3A49Z&sig=xxxx";
string url = "https://xxxx.dfs.core.windows.net/myfilesys1/app.JPG" + sasToken;
var req = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
req.Method = "HEAD";
var res = (HttpWebResponse)req.GetResponse();
Console.WriteLine("the status code is: "+res.StatusCode);
var headers = res.Headers;
Console.WriteLine("the count of the headers is: "+headers.Count);
Console.WriteLine("*********");
Console.WriteLine();
//list all the properties if you don't know which correct format of property.
foreach (var h in headers.Keys)
{
Console.WriteLine(h.ToString());
}
Console.WriteLine("*********");
Console.WriteLine();
//take the Content-Type property for example.
var myheader = res.GetResponseHeader("Content-Type");
Console.WriteLine($"the header Content-Type is: {myheader}");
Console.ReadLine();
}
}
}
Result:
If you don't know how to generate sas token, you can nav to azure portal -> your storage account, then follow the screenshot below:
这篇关于如何获取ADLS Gen2中存储的文件的MD5?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!