【问题标题】:How to download an image to android device from azure blob using c# and Xamarin如何使用 c# 和 Xamarin 从 azure blob 将图像下载到 android 设备
【发布时间】:2016-08-09 00:42:03
【问题描述】:

我想将图像从 Azure blob 存储到 android 设备。我正在使用 Xamarin、C# 来开发 android 应用程序。 我可以在测试时将文件保存在本地系统中,但是当我将代码部署到移动设备时,文件没有保存在设备中。

  CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
            // Retrieve storage account from connection string.
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

            // Retrieve reference to a previously created container.
            CloudBlobContainer container = blobClient.GetContainerReference("blob");
foreach (IListBlobItem item in container.ListBlobs(null, false))
            {
               if (item.GetType() == typeof(CloudBlockBlob))
                {
                    CloudBlockBlob pageBlob = (CloudBlockBlob)item;
                    string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                    pageBlob.DownloadToFile(documentsPath+"inage.jpg",FileMode.Create);
                    //pageBlob.DownloadToByteArray(documentsPath + @"\inage.jpg", FileMode.);


                }
            }

【问题讨论】:

  • 你有什么异常吗?您是否注意到“inage,jpg”中的拼写错误?尝试将一些文本文件保存到个人文件夹,可能是您无权写入。

标签: android c#-4.0 xamarin.android azure-mobile-services azure-blob-storage


【解决方案1】:

您是否已经在使用 Azure 移动?如果是这样,则有一个用于 Blob 存储的内置功能,但它位于较新的服务 Azure 移动应用程序中。我来自产品团队,我们建议新项目使用 Azure 移动应用而不是移动服务。如需更多信息,请参阅I use Mobile Services, how does App Service help?

以下是有关如何在 Xamarin.Forms 中执行此操作的教程:Connect to Azure Storage in your Xamarin.Forms app

【讨论】:

    猜你喜欢
    • 2021-12-12
    • 1970-01-01
    • 2019-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-21
    • 1970-01-01
    • 2018-08-03
    相关资源
    最近更新 更多