[英]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。
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.