WP8 +将文件上传到Skydrive [英] WP8 + Upload File to Skydrive

查看:84
本文介绍了WP8 +将文件上传到Skydrive的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一个简单的.cer文件上传到SkyDrive.不管我使用什么LiveConnectClient-Method,都不会发生.没有编译,运行时或其他异常,我的应用程序从未收到LiveOperationResult.我正在使用仿真器,并且能够登录MS Live(因此我的Internet连接很好).这是所用代码的摘录:

I'm trying to upload a simple .cer file to SkyDrive. Regardless of the LiveConnectClient-Method I use, nothing happens. There is no compile, runtime or other Exception and my app never receives a LiveOperationResult. I'm using the emulator, and I'm able to log in to MS Live (so my internet connection is fine). Here is a excerpt of the code used:

using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
{
  using(var fileStream = store.OpenFile(certPath, FileMode.Open, FileAccess.Read, FileShare.Read))
  {
    try
    {
      client = new LiveConnectClient(session);
      //LiveOperationResult operationResult = await client.UploadAsync("me/skydrive", certPath, fileStream, OverwriteOption.Overwrite, new System.Threading.CancellationToken(false), null);
      LiveOperationResult res= await client.BackgroundUploadAsync("me/skydrive",
                                                                  new Uri("/shared/transfers/cert.cer", UriKind.Relative),
                                                                  OverwriteOption.Overwrite);
      linkTextBlock.Text = "Done";

如前所述,TextBlock从不显示完成".使用UploadAsyncBackgroundUploadAsync方法没有区别.

As mentioned before, the TextBlock never Displays "Done". It makes no difference if the UploadAsync or BackgroundUploadAsync method is used.

推荐答案

BackgroundUploadAsync使用

BackgroundUploadAsync uses Windows Phone background file transfers which is an intelligent file upload & download scheduling system. Whereas UploadAsync uses immediate HTTP file uploads and downloads.

通过使用后台文件传输,您同意上传的以下限制:

By using Background file transfers you're agreeing to the following limitations on your upload:

最大上传文件大小

通过蜂窝连接-5 MB

Over cellular connection - 5 MB

通过具有电池电源的Wi-Fi连接-20 MB

Over Wi-Fi connection with battery power - 20 MB

通过具有外部电源的Wi-Fi连接-100 MB

Over Wi-Fi connection with external power - 100 MB

队列上载的最大数量也有限制&下载和其他限制.阅读完整的文档@ http://msdn.microsoft.com/zh-CN/library/windowsphone/develop/hh202955(v=vs.105).aspx

There are also limits on the maximum number of queues uploads & downloads and other limitations. Read the full documentation @ http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202955(v=vs.105).aspx

所有这些限制可能导致您的 async await 等待.即使很痛苦,后台文件传输所设置的限制仍可带来最佳的用户体验(即在关闭应用程序时出现赞扬),最佳的电池寿命和最佳的蜂窝数据使用率.最终,由您的应用程序决定要使用直接的WebRequests(uploadAsync)还是后台文件传输(BackgroundUploadAsync).

All of these limitations are probably causing your async await to wait. Even though it's a pain the limits set forth by background file transfers lead to the best user experience (i.e. uplaods when the app is closed), best battery life and best cellular data usage. Ultimately it's up to your app to decide if you want to use straight up WebRequests (uploadAsync) or background file transfers (BackgroundUploadAsync).

这篇关于WP8 +将文件上传到Skydrive的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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