在Azure Blob存储中跟踪上传进度

问题描述 投票:0回答:1

我正在使用VB.Net构建文件上传功能到Microsoft Azure Blob存储。有没有一种方法可以在不使用Microsoft的数据传输库的情况下跟踪数据传输的进度?这是我的代码:

Public Function isUploaded(ByVal filename As String) As Boolean
    Try



        Dim connectionString As String = "Connection String Here"
        Dim containerName As String = "uploads"


        Dim storageAccount As CloudStorageAccount = CloudStorageAccount.Parse(connectionString)
        Dim blobClient As CloudBlobClient = storageAccount.CreateCloudBlobClient()
        Dim container As CloudBlobContainer = blobClient.GetContainerReference(containerName)
        Dim blockBlob As CloudBlockBlob = container.GetBlockBlobReference(Path.GetFileName(filename).ToString)


        Using FileStream = System.IO.File.OpenRead(filename)
            blockBlob.UploadFromStream(FileStream)
            Return True
        End Using


    Catch ex As Exception
        Return False
        MsgBox(ex.Message)
    End Try
End Function
vb.net azure-storage-blobs
1个回答
0
投票

如果想知道已经上传了多少字节,则可以使用sdk UploadFromStreamAsync中的方法UploadFromStreamAsync。它将处理类Microsoft.Azure.Storage.Blob,该类在单个操作中保存有关请求和响应流的进度数据传输的信息。

StorageProgress

例如

StorageProgress

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.