We Want to Hear From You! What Do You Want to See on the Community? Tell us here!
Forum Discussion
RodFX
9 years agoNew member | Level 2
How catch error 409 (path/not_found/.) when try download file?
Use a Dropbox-sdk.min.js
<script src="http://bootboxjs.com/bootbox.js"></script> <script src="https://unpkg.com/dropbox/dist/Dropbox-sdk.min.js"></script> dialog.modal('show'); var ACCESS_TOKEN = '<?php echo DROPBOX_ACCESS_TOKEN;?>'; var dbx = new Dropbox({ accessToken: ACCESS_TOKEN }); dbx.filesDownload({ path: "/" + id }) .then(function(data) { dialog.modal('hide'); if (data.fileBlob != null) { var downloadUrl = URL.createObjectURL(data.fileBlob); var downloadButton = document.createElement('a'); document.body.appendChild(downloadButton); downloadButton.setAttribute('href', downloadUrl); downloadButton.setAttribute('download', data.name); downloadButton.click(); window.URL.revokeObjectURL(downloadUrl); document.body.removeChild(downloadButton); } else { bootbox.alert({ message: "Error " + id + " dont exist." }); } }) .catch(function(data) { dialog.modal('hide'); bootbox.alert({ message: "Fail " + id + " wait" }); });
9 Replies
- Greg-DB9 years ago
Dropbox Community Moderator
If the file isn't found, your catch block should get run, with the data variable containing the error information. Is that not running for you? - RodFX9 years agoNew member | Level 2
Is not running the cath.
Look:
POST https://content.dropboxapi.com/2/files/download 409 (path/not_found/.) f.end @ Dropbox-sdk.min.js:8 p @ Dropbox-sdk.min.js:8 D @ Dropbox-sdk.min.js:8 X @ Dropbox-sdk.min.js:8 i @ Dropbox-sdk.min.js:8 n.request @ Dropbox-sdk.min.js:8 r.filesDownload @ Dropbox-sdk.min.js:8 descargar @ factura:264 onclick @ factura:1 Dropbox-sdk.min.js:8 XHR finished loading: POST "https://content.dropboxapi.com/2/files/download". f.end @ Dropbox-sdk.min.js:8 p @ Dropbox-sdk.min.js:8 D @ Dropbox-sdk.min.js:8 X @ Dropbox-sdk.min.js:8 i @ Dropbox-sdk.min.js:8 n.request @ Dropbox-sdk.min.js:8 r.filesDownload @ Dropbox-sdk.min.js:8 descargar @ factura:264 onclick @ factura:1 Dropbox-sdk.min.js:8 Uncaught DOMException: Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was 'blob'). at f.<anonymous> (https://unpkg.com/dropbox@2.5.0/dist/Dropbox-sdk.min.js:8:8015) at f.n.emit (https://unpkg.com/dropbox@2.5.0/dist/Dropbox-sdk.min.js:8:17283) at XMLHttpRequest.r.onreadystatechange (https://unpkg.com/dropbox@2.5.0/dist/Dropbox-sdk.min.js:8:12844) (anonymous) @ Dropbox-sdk.min.js:8 n.emit @ Dropbox-sdk.min.js:8 r.onreadystatechange @ Dropbox-sdk.min.js:8
- Greg-DB9 years ago
Dropbox Community Moderator
Thanks! We'll look into it.
- RodFX9 years agoNew member | Level 2How catch the error ritht now?
- RodFX9 years agoNew member | Level 2I try with:
window.onerror = function() {
}; - Greg-DB9 years ago
Dropbox Community Moderator
This is a bug with the library itself, and not something you should have to handle yourself. We're looking into it, but I don't have a timeline for a fix right now. - RodFX9 years agoNew member | Level 2How can i help you?
- Greg-DB9 years ago
Dropbox Community Moderator
We're able to reproduce the issue, so we shouldn't need any more information from your side. Thanks though! - Greg-DB8 years ago
Dropbox Community Moderator
This should be fixed and no longer throw a `DOMException` as of v3.0.0.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,036 PostsLatest Activity: 7 hours ago
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!