Backstory
I have a bunch of small PDFs (18 kb each).
filesUpload worked until I understood that a `429` is quite usual.
Researched and found the batch endpoints.
I wanted to use `/upload_session/start_batch`, `/upload_session/append_batch` & `/upload_session/finish_batch` to upload all files in a session.
For stability I used the JS SDK.....but there is no method for `/upload_session/append_batch` 🧐
I created my own method and used the endpoint directly.....worked.
But I got errors in the `finish_batch`
Then I thought: If the file size off all PDFs is so small, maybe I can upload them directly in the `start` without any `append` and without batch session.
I thought, I can use the one `session_id` returned by the `filesUploadSessionStart` method and then go with `filesUploadSessionFinishBatchV2` and split the uploaded file into the original PDFs.
const allContent = concatArrayBuffers(...files.map(({ contents }) => contents));
const startResponse = await dbx.filesUploadSessionStart({
close: true,
contents: allContent,
});
const batchData = files.reduce(
(acc, cur) => {
acc.entries.push({
cursor: {
session_id: startResponse.result.session_id,
offset: acc.offset,
},
commit: {
autorename: true,
mode: "add",
mute: false,
path: cur.path,
},
});
acc.offset += cur.contents.byteLength;
return acc;
},
{
offset: 0,
entries: [],
}
).entries;
await dbx.filesUploadSessionFinishBatchV2({
entries: batchData.map(({ commit, cursor }) => ({ commit, cursor })),
});This is the code.
Questions
- What is a session exactly?
- What is an entry exactly?
- Can I access one session from multiple entries in a `filesUploadSessionFinishBatchV2`?
- Where am I going wrong?