Error handling in'Javascript Preview SDK'
Hi,
I'm using Javascript Preview SDK
https://cdn01.boxcdn.net/platform/preview/0.96.0/en-US/preview.js
https://cdn01.boxcdn.net/platform/preview/0.96.0/en-US/preview.css
I've used below method to preview multiple files,
Box.Preview.show(fileId, accessToken, {
container: '.preview-container',
sharedLink: 'https://app.box.com/v/foo',
sharedLinkPassword: 'bar',
collection: [fileId, '123', '234', ...],
header: 'light',
logoUrl: 'http://i.imgur.com/xh8j3E2.png',
showDownload: true,
});
When access token expired i'm getting error like "We're sorry, the preview didn't load. Please refresh the page."
How can I catch, access token expired moment. So that I can call new access token api.
Thanks in advance.
-
Thanks for your response.
Currently I've taken advantage of load event to handle this situation. Like,
Box.Preview.on("load",function(resp){ if( typeof resp.error !== 'undefined' )
Box.Preview.updateToken(); });response:
{
"error":"We're sorry, the preview didn't load. Please refresh the page.", "metrics":{
"locale":"en-US", "event":"preview", "browser":{ "name":"Chrome","swf":true,"svg":true,"mse":true,"webgl":true,"mp3":true,"dash":true,"box3d":true, "h264":{"baseline":true,"main":true,"high":true} }, "converted":true,"cache":{"hit":false,"stale":false}, "time":{"conversion":0,"rendering":398,"total":398}, "count":{"success":0,"error":1,"navigation":0}}, "file":{"id":""}
}Here, When I call update token method,
Box.Preview.updateToken();
Its doing two tasks
1. Updates the token - Worked.
2. Retries to load the current file which was failed. - Not Working, Still failing to load,
Issue might be, cached requests of current file. Because, viewing any other file in the collection loads fine. after that if I try to view the failed file that also works.
Please help me to resolve this issue.
サインインしてコメントを残してください。
コメント
2件のコメント