Xamarin表单-如何在UWP中从Google云端硬盘上传,删除,下载文件 [英] Xamarin Form - How to upload,Delete,Download Files From Google Drive in UWP

查看:111
本文介绍了Xamarin表单-如何在UWP中从Google云端硬盘上传,删除,下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,我想在Google云端硬盘上上传图片,文件.因此,我已经安装了Google.Apis.AuthGoogle.Apis.Drive.v3 nuget软件包.

Hello friend I want to upload an images,files on Google Drive. So I have installed the Google.Apis.Auth and Google.Apis.Drive.v3 nuget packages.

我还通过引用视频https://www.youtube.com/watch?v=xtqpWG5KDXYNow创建了Client_secrete.json文件.问题,如何使用此Client_secrete.json文件并从uwp中的Google云端硬盘上载,下载,删除文件? :(

I have also created the Client_secrete.json file by referring video https://www.youtube.com/watch?v=xtqpWG5KDXYNow. Question, how to use this Client_secrete.json file and upload, download, delete the files from the Google Drive in uwp ? :(

如果有任何想法,请分享代码或链接.

Any idea then please share code or link.

预先感谢:)...

  public static DriveService GetService()
    {
        UserCredential credential;
        DriveService service = new DriveService();
        using (var stream = new FileStream(destinationFolder.Path + @"\client_secret.json", FileMode.Open, FileAccess.Read))
        {
            String FolderPath = destinationFolder.Path;
            String FilePath = Path.Combine(FolderPath, 
"DriveServiceCredentials.json");
            credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                GoogleClientSecrets.Load(stream).Secrets,
                Scopes,
                "users",
                CancellationToken.None,
                new FileDataStore(FilePath, true)).Result;   // Here i got 
the exception.

            service = new DriveService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "DemoDrive",
            });

        }
        return service;

    }

当我尝试运行此代码时,它给出了错误. :(如何解决这个问题.....

When i am trying to run this code it gives error. :( how to solve this.....

推荐答案

请检查 OneDrive 进行替换.并且我们提供了 OneDrive服务 api,它可以实现云驱动器立即.

Please check Google.Apis.Drive.v3, the nuget package incompatible platform contain uwp and Xamarin. So, you could not use it for xamarin.uwp app. For cloud drive within uwp platform, we suggest you use OneDrive to replace. And we have provide OneDrive Service api that could implement cloud drive immediately.

这篇关于Xamarin表单-如何在UWP中从Google云端硬盘上传,删除,下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆