[英]Get progress during blob file upload on Azure Android Storage SDK
我正在使用这种方法在Blob上上传一些文件(有些文件很大,需要几分钟才能上传)。
private void updateFilesOnBlob(){
try {
String timestamp = Tools.generateTimeStamp();
// Retrieve storage account from connection-string.
CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString);
// Create the blob client.
CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.getContainerReference(CONTAINER_NAME);
// Upload each file on Blob
for (int i = 0; i< pathsArrayList.size(); i++) {
// Define the path to a local file.
final String filePath = pathsArrayList.get(i);
CloudBlockBlob blob = container.getBlockBlobReference(timestamp + "/" + filenameFromPath(pathsArrayList.get(i)));
File source = new File(filePath);
blob.upload(new FileInputStream(source), source.length());
}
}
catch (Exception e)
{
// Output the stack trace.
e.printStackTrace();
}
}
如您所见,我使用blob.upload()
开始上传文件。 有什么办法可以取得进度百分比吗?
当然,我正在AsyncTask的doInBackground
运行此方法,因此在onProgressUpdate()
更新UI应该很容易。 我只需要知道上传过程的进度即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.