Reputation: 47
I am try to read and write to a file on my Dropbox using the new Drobox API, I have already created a variable that can access my account and have been able to list the contents of my Dropbox, but so far I have not been able to get a specific files contents. What I recieve in the console output is,
todocl.file - The file path, which is 'Test.txt' (I have tried '/Test.txt', that just gives a 409 error, path not found.)
and
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').
function readFiles() {
todocl.dbx.filesDownload({
path: '/Help.txt'
}).then(function (response) {
var text = response.fileBlob;
var reader = new FileEventListener("loadend", function () {
console.log(reader.result);
});
reader.readAsText(text);
}).catch(function (error) {
console.error(error);
});
}
Dropbox Api http://dropbox.github.io/dropbox-sdk-js/Dropbox.html
Any help would be great!
Upvotes: 0
Views: 1159
Reputation: 47
Turns out I needed the root for the file path and the corretc setu for the filee reader.
function readFiles() {
todocl.dbx.filesDownload({
path: todocl.file
}).then(function (data) {
var blob = data.fileBlob;
var reader = new FileReader()
reader.addEventListener("loadend", function () {
console.log(reader.result);
})
reader.readAsText(blob);
}).catch(function (error) {
console.error(error);
});
}
Upvotes: 2