【问题标题】:Uploading image too Google Drive using Google Drive APIs on Windows Phone 7.1 C#在 Windows Phone 7.1 C# 上使用 Google Drive API 将图像上传到 Google Drive
【发布时间】:2015-03-25 17:18:26
【问题描述】:

我是开发 Windows Phone 应用程序的新手。此外,我的笔记本电脑太旧了,无法在其上开发或使用 Emulator for Windows Phone 7.5 或更高版本,所以我必须坚持使用旧的 WP7.1

我想将选定的图像上传到谷歌驱动器。我创建了一个按钮来浏览图像和一个“图像容器”在选择后显示它。使用下面的代码在这里完成。但是在显示之后,我希望上传过程也从这里开始。但是问题一开始就出现了。

    private void browseButton_Click(object sender, RoutedEventArgs e)
    {

        PhotoChooserTask photo = new PhotoChooserTask();
        photo.ShowCamera = true;
        photo.Show();
        photo.Completed += new EventHandler<PhotoResult>(browseButton_Click_Conpleted);
    }


    private void browseButton_Click_Conpleted(object sender, PhotoResult e)
    {
        BitmapImage image = new BitmapImage();
        image.SetSource(e.ChosenPhoto);
        displayIMG.Source = image;

        //It works until now

        //Below is the code I copied from many place that will authorize me to upload to their drive.
        string[] scopes = new string[] { DriveService.Scope.Drive,
                             DriveService.Scope.DriveFile};

        UserCredential credential =
                    GoogleWebAuthorizationBroker
                                  .AuthorizeAsync(new ClientSecrets
                                  {
                                      ClientId = "MY_CLIENT_ID_HERE"
                                  ,
                                      ClientSecret = ""MY_SECRET_ID_HERE"
                                  }
                                                  , scopes
                                                  , Environment.UserName
                                                  , CancellationToken.None
                                                  , new FileDataStore("Daimto.GoogleDrive.Auth.Store")
                                                  ).Result;

    }

它显示了很多错误,因为它无法识别某些类型或命名空间,不建议使用using。我创建了一个以 WP8.0 为目标的新项目,希望它能识别除Environment.UserNamenew FileDataStore 等仍然缺失的所有内容。我已经添加了Google.Apis.Drive.v2 client library 我不知道我错过了什么。

我的首要任务是在 WP7.1 上开发。我不想仅仅因为这个而购买新手机。对不起我的英语。

【问题讨论】:

    标签: c# api windows-phone-8 google-api windows-phone


    【解决方案1】:

    您是否尝试过PedroLamas 示例以便将文件上传到GDrive

    【讨论】:

    • 能够测试 PedroLamas 并成功将图像上传到谷歌驱动器。现在我正在我自己的应用程序中使用它。感谢您的帮助,它节省了时间
    猜你喜欢
    • 2020-11-03
    • 2020-03-10
    • 2016-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多