WP8 - 批量上传图像到azure存储

时间:2015-02-06 10:03:29

标签: windows-phone-8 azure-storage-blobs cameracapturetask

我正在尝试从我的Windows Phone 8上传图像到azure blob存储。我正在使用CameraCaptureTask,下面的代码可以很好地将图像上传到azure存储。但是,有没有办法一次上传多个图像?

    private void save_Click(object sender, RoutedEventArgs e)
    {
        UploadToAzureBlobStorage(imageStream);
    }

    private void capture_Click(object sender, RoutedEventArgs e)
    {
        cam.Show();
    }

    void cam_Completed(object sender, PhotoResult e)
    {
        if (e.TaskResult == TaskResult.OK)
        {
            BitmapImage bmp = new BitmapImage();
            bmp.SetSource(e.ChosenPhoto);

            imagestream = e.ChosenPhoto;
        }
    }

    private void UploadToAzureBlobStorage(Stream stream)
    {
        var blobClient = CloudStorageContext.Current.Resolver.CreateCloudBlobClient();
        var container = blobClient.GetContainerReference("images");

        container.CreateIfNotExist(
            BlobContainerPublicAccessType.Container,
            response =>
            {
                var blob = container.GetBlobReference("image.jpg");

                blob.UploadFromStream(
                    stream,
                    response2 =>
                    {
                        MessageBox.Show("Upload complete.");
                    });
            });
    }

1 个答案:

答案 0 :(得分:0)

存储客户端库允许您上载/下载单个blob。您当然可以使用标准.NET技术并行执行多个blob操作。