如何使用邮递员将图像上传到Azure Blob存储 [英] How to upload images using postman to azure blob storage

查看:71
本文介绍了如何使用邮递员将图像上传到Azure Blob存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用邮递员将图像上传到我的Blob容器文件夹,以下是屏幕截图

I have been trying to upload an image to my blob container folder using postman,Below is the screenshot

此处是链接 Azure存储服务REST API的授权用来生成签名,并在正文时在正文中附加文件名文件字段.

Here is the link Authorization of Azure Storage service REST API am using to generate signature and am attaching filename file field in the body while body.

var key = "[Storage account key]";
var strTime = (new Date()).toUTCString();
var strToSign = 'PUT\n\nimage/jpeg; charset=UTF-8\n\nx-ms-date:' + strTime + '\nx-ms-meta-m1:v1\nx-ms-meta-m2:v2\n/colony7/folder-customer-profilepic/Home - explorar.jpg';
var secret = CryptoJS.enc.Base64.parse(key);
var hash = CryptoJS.HmacSHA256(strToSign, secret);
var hashInBase64 = CryptoJS.enc.Base64.stringify(hash);
var auth = "SharedKey colony7:"+hashInBase64; 

我已经使用了这些 https://docs.microsoft .com/en-us/rest/api/storageservices/put-block

I have used these https://docs.microsoft.com/en-us/rest/api/storageservices/put-block ,https://docs.microsoft.com/en-us/rest/api/storageservices/authentication-for-the-azure-storage-services references for above code.

我也打开了cors.请分享有关如何使用邮递员将jpg或png图像上传到我的Blob的解决方案.

I have turned on cors also. Kindly share the solution as to how would i upload a jpg or png image to my blob using postman.

预先感谢

推荐答案

如果我们要将图像上传到Azure存储,请尝试使用

If we want to upload an image to the azure storage, please have a try to use the Put blob API not Put block API.

并尝试使用以下strToSign.

And have a try to use the following strToSign.

"PUT\n\n\n{Content-Length}\n\n{Content-Type}\n\n\n\n\n\n\nx-ms-blob-type:BlockBlob\nx-ms-date:{date}\nx-ms-version:2015-12-11\n/accountname/container/blobname"   

我在我这边对其进行了测试,它可以在现场正常运行.

I test it on my side, it works correctly on site.

标题:

身体:

注意:我们可以从文件大小中获取Content-Length.

Note: we could get the Content-Length from the file size.

这篇关于如何使用邮递员将图像上传到Azure Blob存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆