cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How catch error 409 (path/not_found/.) when try download file?

How catch error 409 (path/not_found/.) when try download file?

RodFX
New member | Level 2

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 9

Greg-DB
Dropbox Staff
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?

RodFX
New 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-DB
Dropbox Staff

Thanks! We'll look into it.

RodFX
New member | Level 2
How catch the error ritht now?

RodFX
New member | Level 2
I try with:

window.onerror = function() {
};

Greg-DB
Dropbox Staff
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.

RodFX
New member | Level 2
How can i help you?

Greg-DB
Dropbox Staff
We're able to reproduce the issue, so we shouldn't need any more information from your side. Thanks though!

Greg-DB
Dropbox Staff
This should be fixed and no longer throw a `DOMException` as of v3.0.0.
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    RodFX New member | Level 2
What do Dropbox user levels mean?