问题描述
你好朋友,我想在Google云端硬盘上上传图片,文件.因此,我已经安装了Google.Apis.Auth
和Google.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.....
推荐答案
请检查 Google.Apis.Drive.v3
,与nuget包不兼容的平台包含uwp和Xamarin.因此,您不能将其用于xamarin.uwp应用程序.对于uwp平台内的云驱动器,建议您使用 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云端硬盘上传,删除,下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!