Azure的CloudBlob SetMetadata失败"指定的元数据是无效的。它有不允许的字符&QUOT。 [英] Azure CloudBlob SetMetadata fails with "The metadata specified is invalid. It has characters that are not permitted."
问题描述
我是pretty知道这是在Windows Azure SDK的限制(使用最新的1.4),但一定是解决的办法,而无需使用人工REST ...
I'm pretty sure this is a limitation of the Windows Azure SDK (Using the latest, 1.4), but there has got to be a way around this without using manual REST...
在code:
CloudBlob blob = container.GetBlobReference(url); // works
blob.UploadByteArray(bytes); // works
blob.Metadata["test"] = "public, max-age=259200"; // works
// FAILS with "The metadata specified is invalid. It has characters that are not permitted."
blob.Metadata["x-ms-blob-cache-control"] = "public, max-age=259200";
blob.SetMetadata(); // FAILS due to the 2nd meta data
这是pretty从我的测试中明确指出,客户端吹起来,由于这些破折号 - ,但我想不出解决这个办法。设置缓存控制是非常重要的,常见的操作,这令我感到困惑,为什么我找不到其他任何人对这个问题的报告。
It's pretty clear from my tests that the client is blowing up due to these dashes '-', but I cannot think of any way around this. Setting cache control is very important, and common operation, which baffles me as to why I cannot find anyone else reporting on this problem.
我也试过的数据,这在技术上不应该是必要的编码,但绝望的我就是这么做的。想法?
I've also tried encoding the data, which technically shouldn't be necessary, but out of desperation I did it anyway. Ideas?
推荐答案
它结束了一个愚蠢的SDK的限制毕竟还有是轮流设置为你具体的元数据...我不特定属性考虑到这一点属性作为帮手,但我看不出有任何理由直接设置应元无法正常工作。
It ended up being a silly SDK limitation after all, there is a specific property which in turns sets that specific meta data for you... I don't mind having this property as a helper, but I see no reason why setting the meta directly shouldn't work.
blob.Properties.CacheControl = "public, max-age=259200";
blob.UploadByteArray(bytes);
这篇关于Azure的CloudBlob SetMetadata失败"指定的元数据是无效的。它有不允许的字符&QUOT。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!