问题
This is how I try to upload an image to Azure blog storage, then upload an empty file located there.


I try to upload this image here:
CloudStorageAccount storageAccount = new CloudStorageAccount(new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(Accountname, KeyValue), true);
// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve a reference to a container.
CloudBlobContainer container = blobClient.GetContainerReference(ContainerValue);
CloudBlockBlob blockBlob = container.GetBlockBlobReference(filename);
using (var f = System.IO.File.Open(model.FileToUpload.FileName, FileMode.Create))
{
await blockBlob.UploadFromStreamAsync(f);
}
But if i try to open this image say this.

回答1:
As Marco said, FileMode.Create specifies that the operating system should create a new file. If the file already exists, it will be overwritten. For more details, you could refer to this article.
According to the pictures you provided, your blob size is 0 B. So, you would always couldn't find the file and open it. FileMode specifies how the operating system should open a file.
So I suggest that you could delete it and use OpenRead to open an existing file for reading. You could refer to the code as below:
using (var f = System.IO.File.OpenRead(model.FileToUpload.FileName))
{
await blockBlob.UploadFromStreamAsync(f);
}
来源:https://stackoverflow.com/questions/48664217/empty-image-from-blob-storage