我只是将json文件写入Blob(请参阅下面的代码)。我需要它为content = application / json,但是blob json文件每次都会读取“ application / octet-stream”。我已经将blob.properties ContentType设置为=“ application / json”,但是当我在Storage Explorer中查看时,每次都会显示“ application / octet-stream”。
请协助;这让我发疯:-)
谢谢
迈克
在此处输入代码
static public void WriteBlob(string filename, string data)
{
string storageConnectionString = "DefaultEndpointsProtocol=https;AccountName=scadametrics;AccountKey=xxxxxxxxxxnfrsFRd/49Dmhn0HwKbxmpiA==;EndpointSuffix=core.windows.net";
var storageAccount = CloudStorageAccount.Parse(storageConnectionString);
var client = storageAccount.CreateCloudBlobClient();
var container = client.GetContainerReference("azfunc-out");
// string fileName = companyId.ToString() + "\\" + Guid.NewGuid();
var blob = container.GetBlockBlobReference(filename);
blob.Properties.ContentType = "application/json";
using (CloudBlobStream x = blob.OpenWriteAsync().Result)
{
byte[] bytes = Encoding.ASCII.GetBytes(data);
x.Write(bytes, 0, bytes.Length);
x.Flush();
x.Close();
}
}
答案 0 :(得分:0)
您应该致电blob.SetPropertiesAsync
,将内容类型真正保存到服务器。