以下块是Azure Blob存储在请求XML格式的容器列表时返回的内容。
<Blob>
<Name>commits-dump.2015-10-03.tar.gz</Name>
<Url>https://ghtstorage.blob.core.windows.net/downloads/commits-dump.2015-10-03.tar.gz</Url>
<Properties>
<Last-Modified>Wed, 09 Dec 2015 18:48:28 GMT</Last-Modified>
<Etag>0x8D300C95405378B</Etag>
<Content-Length>189598959329</Content-Length>
<Content-Type>application/octet-stream</Content-Type>
<Content-Encoding/>
<Content-Language/>
<Content-MD5>gzmOYbF+TJGlvQTKPz84PQ==</Content-MD5>
<Cache-Control/>
<BlobType>BlockBlob</BlobType>
<LeaseStatus>unlocked</LeaseStatus>
</Properties>
</Blob>
我的问题是:如何解析Content-MD5
字段(在Ruby / Python中)并将其转换为Linux md5sum
实用程序所期望的字段?
对于此特定文件,等效的md5sum为:83398e61b17e4c91a5bd4ca3f3f383d
答案 0 :(得分:1)
要回答我自己的问题,以下Ruby代码可以运行:
irb(main):012:0> require 'base64'
irb(main):013:0> Base64.decode64("gzmOYbF+TJGlvQTKPz84PQ==").each_byte.map { |b| b.to_s(16) }.join == "83398e61b17e4c91a5bd4ca3f3f383d"
=> true
答案 1 :(得分:0)
您可以从本地文件创建md5并与天蓝色内容md5
进行比较python中的Bellow代码
function poll() {
$.get('http://your-api-endpoint.com')
.done(function() {
// 200 - OK response
})
.fail(function() {
// Error Response
})
.always(function () {
setTimeout(function() {
poll();
}, 5000);
});
}
poll();