在REST请求集元数据把一滴在AZURE

在REST请求集元数据把一滴在AZURE

本文介绍了在REST请求集元数据把一滴在AZURE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够利用Azure的提供REST API来上传文件到蔚蓝的斑点。

i am able to upload file to azure blob using REST api provided by Azure.

我想在我做了放一滴请求的时间设置的元数据,如图所示的我是unble上传文件,并得到以下异常 org.apache.http.client.ClientProtocolException

i want to set metadata at the time i am doing request for put blob, when i am setting it into header as shown here i am unble to upload file and getting following exception org.apache.http.client.ClientProtocolException.

从code以下的最后一行

from the last line of the code below

    HttpPut req = new HttpPut(uri);
    req.setHeader("x-ms-blob-type", blobType);
    req.setHeader("x-ms-date", date);
    req.setHeader("x-ms-version", storageServiceVersion);
    req.setHeader("x-ms-meta-Cat", user);
    req.setHeader("Authorization", authorizationHeader);

    HttpEntity entity = new InputStreamEntity(is,blobLength);
    req.setEntity(entity);

    HttpResponse response = httpClient.execute(req);

就同​​一

,我有两个问题。

regarding the same, i have two questions.


  1. 可以设置不同的元数据,避免文件的覆盖?

如果是针对第一个问题,如何设置的元数据REST请求把一滴到Azure的?

if Yes for first question, how to set metadata in REST request to put blob into Azure?

请帮忙

推荐答案

所以,一些事情会在这里。

So a few things are going here.

对于你得到的错误,这是因为计算授权头,当你不添加元数据标头。请仔细阅读构建规范化的标题字符串部分此处的。

Regarding the error you're getting, it is because you're not adding your metadata header when calculating authorization header. Please read Constructing the Canonicalized Headers String section here: http://msdn.microsoft.com/en-us/library/windowsazure/dd179428.aspx.

,你需要改变code的以下行(从您的博客文章)

Based on this, you would need to change the following line of code (from your blog post)

String canonicalizedHeaders = "x-ms-blob-type:"+blobType+"\nx-ms-date:"+date+"\nx-ms-version:"+storageServiceVersion;

String canonicalizedHeaders = "x-ms-blob-type:"+blobType+"\nx-ms-date:"+date+"\nx-ms-meta-cat"+user+"\nx-ms-version:"+storageServiceVersion;

(注意:我刚才在记事本中做出这些改变,使他们可能无法正常工作,请去我上面提到的正确创建规范化头串链接

(Note: I have just made these changes in Notepad so they may not work. Please go to the link I mentioned above for correctly creating the canonicalized headers string.

可以设置不同的元数据,避免文件的覆盖?

不知道你的意思是什么。您可以通过执行在博客上操作。

Not sure what you mean by this. You can update metadata of a blob by performing Set Blob Metadata operation on a blog.

这篇关于在REST请求集元数据把一滴在AZURE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 12:34