LiveSDK用于通用Windows应用程序后台上传

时间:2014-11-24 16:46:38

标签: c# silverlight windows-phone-8 win-universal-app live-sdk

我正在开发通用Windows应用程序并使用Live SDK 5.6将文件上传到OneDrive。我看到了使用here的示例以及有关版本here的说明。 根据我应该使用的说明:

对于Windows和WP81:CreateBackgroundUploadAsync方法;

对于WP8 Silverlight:BackgroundUploadAsync方法

CreateBackgroundUploadAsync就像在Windows上的魅力一样,并通过LiveOperationProgress返回正确的进度值,但在WP81上它始终显示0%的进度,最后它成为100%。所以它实际上并没有跟踪进度。

然后我尝试使用BackgroundUploadAsync(适用于Silverlight应用)并且可以在手机上运行 - 上传文件并跟踪进度。但是当我尝试上传大文件(在我的情况下> 150Mb)时,我注意到120秒之后上传操作只是重置为0%并重新开始,没有任何例外。

这是适用于Windows和Windows的代码。 WP81方法:

var progressHandler = new Progress<LiveOperationProgress>(
                    (progress) =>
                    {
                        var res = progress.ProgressPercentage;
                    });
LiveUploadOperation uploadOperation = await liveConnectClient.CreateBackgroundUploadAsync(uploadPath, "testfile.wav", file, OverwriteOption.Rename);
LiveOperationResult uploadResult = await uploadOperation.StartAsync(new CancellationToken(), progressHandler);

对于Silverlight:

var progressHandler = new Progress<LiveOperationProgress>(
                    (progress) =>
                    {
                        var res = progress.ProgressPercentage;
                    });
LiveOperationResult opResult = await connectClient.BackgroundUploadAsync(CurrentFolderId,
                                                                      file.Name,
                                                                      stream,
                                                                      OverwriteOption.Rename,
                                                                      record.GetCTS().Token,
                                                                      progressHandler);

所以问题 - 如何让它上传任意大小的文件,重新定义超时(目前是120秒)并跟踪Windows和WP81上的进度?

UPD: 我找到了2分钟超时的原因here

After the connection has been established, an HTTP request message that has not received a response within two minutes is aborted.

PUT请求是否正常?

0 个答案:

没有答案