MVC AZURE从现有blob上传文件图标 [英] MVC AZURE upload file icon from an existing blob
问题描述
嘿所有,
我正在尝试从已上传的blob上传文件图标。我正在使用sasuri用于现有的blob,(我要上传文件图标的那个)。
这样的东西:
Hey all,
I'm trying to upload the file icon from a blob that is already uploaded. I'm using sasuri for the existing blob, (the one i want to upload the fileicon for).
Something like this:
//sasuri function
var SASURI = GetUploadedFileIconSASURL(blobnamehere);
//retrieving fileicon for that blob
var fileIcon = System.Drawing.Icon.ExtractAssociatedIcon(SASURI);
//and then somehow upload the icon as a new blob??
CloudBlobContainer blobContainer = CloudStorageServices.GetCloudBlobContainer();
CloudBlockBlob blockBlob = blobContainer.GetBlockBlobReference(blobiconnamehere);
using (var stream = fileIcon.Openread())
{
blockBlob.UploadFromStream(stream);
}
如何从像这样的变量上传一个blockblob?流不正确,不包含OpenRead的定义。 (我和我一起新手!)
另外,从理论上讲,这会有用吗?图标会保存为图像吗?
提前致谢!!
更新1:
var SASURI = GetUploadedFileIconSASURL(existingBlobNameHere);
var fileIcon = System.Drawing.Icon.ExtractAssociatedIcon(@C:\ WINDOWS \ systemystem \ ptpad.exe);
CloudBlobContainer blobContainer = CloudStorageServices.GetCloudBlobContainer();
CloudBlockBlob blockBlob = blobContainer.GetBlockBlobReference(blobiconnamehere);
位图bmpIcon = fileIcon.ToBitmap();
使用(System.IO.MemoryStream ms = new System.IO.MemoryStream( ))
{
bmpIcon.Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg);
blockBlob.UploadFromStream(ms) ;
}
它的运行但文件icon blob为null(?)
How can I upload a blockblob from a variabel like that? The stream is incorrect, does not contain a definition for OpenRead. (Im a newbie bare with me!)
Also, in theory, would this work? Will the icon be saved as a image?
Thanks in advance!!
Update 1:
var SASURI = GetUploadedFileIconSASURL(existingBlobNameHere);
var fileIcon = System.Drawing.Icon.ExtractAssociatedIcon(@"C:\WINDOWS\system32\notepad.exe");
CloudBlobContainer blobContainer = CloudStorageServices.GetCloudBlobContainer();
CloudBlockBlob blockBlob = blobContainer.GetBlockBlobReference(blobiconnamehere);
Bitmap bmpIcon = fileIcon.ToBitmap();
using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
{
bmpIcon.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
blockBlob.UploadFromStream(ms);
}
Its running but the file icon blob is null(?)
推荐答案
这篇关于MVC AZURE从现有blob上传文件图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!