将图像上传到 Azure blob 存储不支持格式错误

问题描述

将图像上传到 azure blob 后,图像看起来像 https://dodealstorge.blob.core.windows.net/upload/2021-03-31/20210331T071342445.jpg 没有上传正确的 img,我在 Azure 门户中将容器访问级别更改为公开

这是代码

        private async Task<string> UploadFiletoBlobAsync(string strFileName,byte[] fileData,string fileMimeType)
    {
        
            if (fileName != null && fileData != null)
            {
                CloudBlockBlob cloudBlockBlob = cloudBlobContainer.GetBlockBlobReference(fileName);                  
                cloudBlockBlob.Properties.ContentType = fileMimeType;                  
                await cloudBlockBlob.UploadFromByteArrayAsync(fileData,fileData.Length);
                return cloudBlockBlob.Uri.AbsoluteUri;
            }
            return "";
        }
       
    }

控制器:

 var fileName = Path.GetFileName(photoIform.FileName);
                            var fileStream = new FileStream(Path.Combine(uploads,photoIform.FileName),FileMode.Create);
                            string mimeType = photoIform.ContentType;
                            byte[] fileData = new byte[photoIform.Length];
                             // Update
                            photoIform.OpenReadStream(); 
                            BlobStorageService objBlobService = new BlobStorageService();
                            img2.ImgPath = objBlobService.UploadFiletoBlob(photoIform.FileName,fileData,mimeType);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)