Xamarin Form - How to upload,Delete,Download Files From Google Drive in UWP

南笙酒味 提交于 2019-12-08 08:50:58

问题


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.

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.

Thanks in advance :)...

  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.....


回答1:


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.



来源:https://stackoverflow.com/questions/56272752/xamarin-form-how-to-upload-delete-download-files-from-google-drive-in-uwp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!