azure - 使用 REST API 上传 Azure Blob

标签 azure azure-storage azure-blob-storage

我正在使用签名 URL 通过 Air 从移动设备上传 blob。

我有两个问题:

当使用签名 URL 上传 blob 时,我认为不需要包含文档中描述的所有 header 。我是否正确地认为我只需要对 URL 执行 PUT 请求并将编码到正文中的文件包含到 Content-Type 设置为 multipart/表单数据;边界=[[这里的边界]]

var client:HttpClient = new HttpClient();
var request:HttpRequest = new Put();
request.body =  UploaderPostHelper.getPostData( filename,  byteArray);
request.contentType = 'multipart/form-data; boundary=' + UploaderPostHelper.getBoundary();
client.request(new URI(signedUrl), request);

http://msdn.microsoft.com/en-us/library/windowsazure/dd179451.aspx

(UploadPostHelper的源代码在这里https://code.google.com/p/as3asclublib/source/browse/trunk/net/UploadPostHelper.as)

其次,我可以指定我想要使用 POST 请求和 header 执行 PUT 请求吗?

干杯。

最佳答案

When uploading blobs using a signed URL I assume I don't need to include all the headers as described in the documentation.

您需要指定 2 个 header - Content-Lengthx-ms-blob-type。我假设您将文件保存为 block blob,因此 x-ms-blob-type 的值应为 BlockBlob

此外,Content-Type 应该是文件的内容类型,例如plain/txtimage/gif

And secondly, can I specify that I want to do a PUT request using a POST request and a header?

不确定这个。您请求的 HTTP 方法应为 PUT

关于azure - 使用 REST API 上传 Azure Blob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18845793/

相关文章:

azure - 使用 ADAL 库在后台向 Azure 进行身份验证,无需重定向到 Azure 登录门户

azure - Azure AD 中的贡献者角色和存储帐户贡献者角色有什么区别?

即使设置为私有(private)后,Azure blob 容器仍然可以直接访问

azure - 如何从最新的 blob 文件夹 azure blob 容器中获取最新文件?

c# - 使用 .NET Core 3.1 和 HttpContext 的客户端 IP 地址错误

sql-server - django-pyodbc-azure。对象名称无效 'django_session'

azure - 使用 web.config 将 www 站点重定向到非 www 站点

azure - Microsoft 应用程序注册门户无法添加委派和应用程序权限

c# - Azure存储1.7 : how to make a simple select that works everytime?

node.js - Nodejs Azure 存储将 Blob 复制到新 Blob