0
我试图将图像上传到azure blob,但是当我看到blob中上传的图像时,其大小为0字节。无法将图像上传到Azure blob
正如我想出,它正在发生,因为的InputStream的位置属性(HttpPostedFileBase.InputStream)变得等于InputStream的 EX的长度属性:如果InputStream.Length = 41230然后将InputStream.Position也被设置为41230,这不应该发生。理想情况下,它应该是零。
在我的代码我想出这实际上等于设定位置向长度
HttpPostedFileBase file = Request.Files["LayoutLevels[" + i + "].FloorwiseViewPath"];
//Here file.InputStream.Position = 0 which is desired
if (file.ContentLength > 0)
{
//below line causes file.InputStream.Position to change it equal to file.InputStream.Length
using (System.Drawing.Image image = System.Drawing.Image.FromStream(file.InputStream, true, true))
{
if (image.Width <= 720 && image.Height <= 550)
{...
using语句导致该位置属性从0改变为长度的线。
我可以使用语句, 内部手动将位置属性重置为0,但我的问题是,为什么位置正在改变,以及避免它被更改的正确方法是什么?