【发布时间】:2018-08-02 15:59:33
【问题描述】:
场景:
我将 .css 文件从一个子目录复制到 Azure 存储容器中的另一个。它是从我的应用程序中的 C# 代码级别完成的。这是我网站的 css 样式文件。不幸的是,我在加载页面时在浏览器控制台中收到错误:
错误
Resource interpreted as Stylesheet but transferred with MIME type application/octet-stream:
"SOME_PATH/template/css/styles.css?d=00000000-0000-0000-0000-000000000000".
知识:
我知道这就是为什么我的文件作为八位字节流而不是 text/css 发送的原因。我该怎么做才能说 Azure 将此文件视为文本/css?
编辑:我的代码
string newFileName = fileToCopy.Name;
StorageFile newFile = cmsDirectory.GetStorageFileReference(newFileName);
using (var stream = new MemoryStream())
{
fileToCopy.DownloadToStream(stream);
stream.Seek(0, SeekOrigin.Begin);
newFile.UploadFromStream(stream);
}
DownloadToStream 和 UploadToStream 是我班级中的方法:
CloudBlob.DownloadToStream(target);
和
CloudBlob.DownloadToStream(target);
CloudBlob 是 CloudBlockBlob 类型
【问题讨论】:
-
你能添加你现有的代码吗?了解您现在正在使用哪些功能将使人们更容易推荐更改。
-
搞定了,谢谢帮助
标签: azure azure-storage azure-blob-storage