Reputation: 14118
I'm attempting to post a large number of records (2000-ish) to Dropbox via the Datastore JS API. I'm getting this error:
POST https://api12.dropbox.com/1/datastores/put_delta 400 (Bad Request)
...and it references: api12.dropbox.com/1/datastores/put_delta:1
That's not a lot of info to use when debugging, but I'm guess it's because I'm over the size limit.
Any ideas how I can fix this or at least debug it further?
Update
I used the XHR inspector in Chrome to get this response:
{"error":
{
"size_limit": "Error: put_delta of delta (size 4138335) exceeds size limit 2097152 bytes",
"object_type": "delta",
"limit": 2097152,
"size": 4138335
}
}
Upvotes: 0
Views: 178
Reputation: 60153
In the JS SDK, there's an implicit "sync" every time your code yields control back to the browser. So if you write a for loop entering a lot of data, that will all go into a single delta. You can break things up by writing in smaller chunks. For example, something like this (untested, sorry if there's an off-by-one error or the like):
var LIMIT = 100; // how many things to write in a single delta
function writeThings(arrayOfThings) {
// write up to LIMIT things
for (var i = 0; i < arrayOfThings.length && i < LIMIT; i++) {
writeSingleThing(arrayOfThings[i]);
}
if (i < arrayOfThings.length) {
// more to write
window.setTimeout(function () {
// after a tick, continue from where we left off
writeThings(arrayOfThings.slice(i));
}, 1);
} else {
// done writing
}
}
Upvotes: 1