无法使用SkyDrive选取器的上传选项 [英] Can’t use Upload option of SkyDrive picker

查看:90
本文介绍了无法使用SkyDrive选取器的上传选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨小伙伴,

我正在尝试使用Live Connect开发中心页面中的SkyDrive代码示例:

I’m trying to utilize the SkyDrive code samples from the Live Connect Development Center’s page:

I对SkyDrive选择器的OPEN选项没有任何问题。但是当谈到UPLOAD选项时,我遇到了一个奇怪的错误,我几乎要放弃修复。

I have no problem with OPEN option of SkyDrive picker. But when it comes to UPLOAD option I encounter a peculiar bug which I’m almost giving up to fix.

每当我试图访问该页面时,我都会得到"失败"验证"或Pop Ups的资源管理器信号块,之后即使我允许执行弹出窗口,页面也完全空白。"

Whenever I’m trying to access that page I’m ether getting the "Failed to authenticate" or the explorer signaling block of Pop Ups and after that the page is completely blank even if I allow the execution of the pop ups. 

但是在Interactive SDK中它可以正常运行。

However in Interactive SDK it works ok.

如果你能指出我实施中的错误,我将非常感激。

I would be very much grateful if you can point me on the mistake in my implementation.

这是我使用的代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
<h1>Upload Fie</h1>
<div>
  
  <div id="signin"></div>
  
  
</div>
<script src="//js.live.net/v5.0/wl.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript" language="javascript">

    // Update the following values
    var client_id = "XXXXXXXXX",
        scope = ["wl.signin", "wl.basic", "wl.offline_access", "wl.emails", "wl.skydrive_update"],
        redirect_uri = "http://some URL";

//Code from Live Connect Development Center
    WL.init({ client_id: client_id, redirect_uri: redirect_uri });

    WL.login({ "scope": "wl.skydrive_update wl.basic wl.signin" }).then(
    function (response) {
        displayDialog();
        registerOnClickHandlers();
    },
    function (response) {
        log("Failed to authenticate.");
    }
);

    function registerOnClickHandlers() {
        var uploadFileButton =
        document.getElementById('save-to-skydrive-upload-button');
        uploadFileButton.disabled = true;
        uploadFileButton.onclick = function () {
            closeDialog();
            saveToSkyDrive();
        };

        var fileInputElement =
        document.getElementById('save-to-skydrive-file-input');
        fileInputElement.onchange = function () {
            uploadFileButton.disabled = (fileInputElement.value === "");
        };
    }

    function saveToSkyDrive() {
        WL.fileDialog({ mode: 'save' }).then(
        function (response) {
            var folder = response.data.folders[0];

            WL.upload({
                path: folder.id,
                element: 'save-to-skydrive-file-input',
                overwrite: 'rename'
            }).then(
                function (response) {
                    log("You saved to " + response.source + ". " +
                        "Below is the result of the upload.");
                    log("");
                    log(JSON.stringify(response));
                },
                function (errorResponse) {
                    log("WL.upload errorResponse = " + JSON.stringify(errorResponse));
                },
                function (progress) {
                    // progress events for the upload are raised here
                }
            );
        }, function (errorResponse) {
            log("WL.fileDialog errorResponse = " + JSON.stringify(errorResponse));
        }
    );
    }

    function log(message) {
        var child = document.createTextNode(message);
        var parent = document.getElementById('JsOutputDiv') || document.body;
        parent.appendChild(child);
        parent.appendChild(document.createElement("br"));
    }

</script>
</body>
</html>

推荐答案

WL.login将打开一个弹出窗口以显示用户的登录/授权UI。

WL.login will open a popup window in order to show login/authorization UI to the user.

您应该通过用户点击事件来挂接该操作,而不是在加载页面时调用它。否则,除非您在浏览器设置中关闭弹出窗口阻止,否则浏览器将阻止它。

You should hook up that action with a user clicking event instead of calling it when loading a page. Otherwise, the browser will block it unless you turn off popup blocking in the browser settings.

Lin


这篇关于无法使用SkyDrive选取器的上传选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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