简体   繁体   English

当我的应用程序包含查询字符串时,如何使用 OneDrive Web 选择器

[英]How can I use the OneDrive Web picker when my application contains query string

We are using grails to develop our Job portal application.我们正在使用 grails 开发我们的工作门户应用程序。 We have a requirement to download the document from onedrive once the user will apply for any particular job and uploading a doc from onedrive.一旦用户申请任何特定工作并从 onedrive 上传文档,我们就要求从 onedrive 下载文档。 The URL will be different for every job ( http://localhost:8080/apply?jobId=1137 . Here "apply" is a action ) from where we need to load the onedrive.每个作业的 URL 都不同( http://localhost:8080/apply?jobId=1137 。这里“apply”是一个动作),我们需要从那里加载 onedrive。 I put the js code in external script file and include in the apply.gsp and my redirecturl as " http://localhost:8080/apply " in onedrive configuration.我将 js 代码放在外部脚本文件中,并在 onedrive 配置中包含在 apply.gsp 和我的重定向 URL 中作为“ http://localhost:8080/apply ”。 Once I am clicking on the Ondrive option, it is opening the login page in a new window and I could able to choose the file.单击 Ondrive 选项后,它会在新窗口中打开登录页面,我可以选择文件。 And once I click on the "open" button, the request is hitting to the "apply" action in the controller and getting the exception in the new window itself ( getting exception as jobid is missing the new request).一旦我点击“打开”按钮,请求就会点击控制器中的“应用”操作,并在新窗口本身中获取异常(获取异常,因为 jobid 缺少新请求)。 we are unable to get the download url also as the response is not coming back to the same page.我们也无法获取下载 url,因为响应没有返回到同一页面。 we are using OneDrive v5 SDK.我们正在使用 OneDrive v5 SDK。

Please help me how to fix the issue so that the new window will be closed and get the selected docs download url.请帮助我如何解决该问题,以便关闭新窗口并获取选定的文档下载 url。

js file js文件

function launchOneDrivePicker(){函数launchOneDrivePicker(){

    var pickerOptions = { 

          success: function(files) {

            // Handle returned file object(s)

            var filObj = files.values[0];
            var fileName = filObj.fileName
            var fileLink = filObj.link
            var fileSize = filObj.size

            alert("File Name : " + fileName + "  **  fileLink : "+ fileLink +"  **  fileSize : "+fileSize);
          },

          cancel: function() {
              // handle when the user cancels picking a file
          },

          linkType: "webViewLink", // or "downloadLink",
          multiSelect: false // or true
    };
    OneDrive.open(pickerOptions);
  }

Thanks谢谢

Look at the 'Using a custom redirect URI' section from the documentation page: https://dev.onedrive.com/sdk/js-v7/js-picker-open.htm查看文档页面中的“使用自定义重定向 URI”部分: https : //dev.onedrive.com/sdk/js-v7/js-picker-open.htm


To paraphrase:转述:

Make a new separate page containing just the OneDrive script:创建一个仅包含 OneDrive 脚本的新单独页面:

<html>
<script type="text/javascript" src="https://js.live.net/v7.0/OneDrive.js">
</script>
</html>

Reference the new page as the redirect URL in the advanced section of the request在请求的高级部分将新页面作为重定向 URL 引用

var odOptions = {
  clientId: "INSERT-APP-ID-HERE",
  action: "download",
  openInNewWindow: true,
  advanced: {
    redirectUri: "https://contoso.com/filePickerRedirect.htm" <-- new separate page
  },
  success: function(files) { /* success handler */ },
  cancel: function() { /* cancel handler */ },
  error: function(e) { /* error handler */ }
}

Remember to add the new page as an authorised redirect URL for the application.请记住将新页面添加为应用程序的授权重定向 URL。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我的重定向网址包含唯一用户ID时,如何使用OneDrive网络选择器? - How can I use the OneDrive Web picker when my redirect URLs include unique user ids? 如何在我的角度应用程序中获取clientID和重定向URI以从onedrive访问文件 - How can I get the clientID and redirect URI to access files from onedrive in my angular application 如何嵌入我的Web应用程序 - How can I embed my web application 如何检查我的字符串是否在 JavaScript 中包含句点? - How can I check if my string contains a period in JavaScript? 我可以在桌面Web应用程序中使用IndexedDB吗 - Can I use IndexedDB in my Desktop Web application Javascript:如何找到Web应用程序中String.format()的声明位置? - Javascript: How can I find where String.format() is declared in my web application? 如何将Kotlin代码编译为JavaScript以在LibGDX Web应用程序中使用? - How can I compile Kotlin code to JavaScript for use in my LibGDX web application? 如何在我的Web应用程序中使用单个模式,并避免每个页面上出现重复的html? - How can I use a single modal across my web application and avoid repetative html on every page? 如何捕获在我的应用程序中播放的音频流,然后将其用作 Web Audio API 的有效输入以进行可视化? - How can I capture an audio stream playing in my application, and then it use it as a valid input for Web Audio API for visualization? 我如何在Web视图Android应用程序中使用Polymer项目 - How can i use Polymer project in my web view Android Application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM