I have web application that can download from dropbox.com. The application is written using Javascript. I'm using the dropbox.min.js
http://code.google.com/p/dropbox-js/ library running on a client.
This is a function of the library:
client.readFile(name, function(error, data) {
if (error) {
return showError(error); // Something went wrong.
}
saveFile(name, data);
});
saveFile(name, data)
is my function doing the following:
var saveFile = function(file, data)
{
var xmlhttp = getXmlHttp();
xmlhttp.open('POST', 'saving.php', true);
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlhttp.send("fileName=" + file + "&data=" + data);
}
function getXmlHttp(){
var xmlhttp;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
The problem is: while I'm trying to download assets (e.g. jpg doc, gif, etc.), I only receive 1kb instead of the full file. Are there any workarounds?