I have a bunch of files across a bunch of directories, so I modified it to support that, would love to see official support
async uploadMultiple2(
albumId,
files, // { name: 'filename', path: 'filepath', description: 'description' }
requestDelay = 10000,
requestTimeout = 10000
) {
const url = `${constants.BASE_PATH}/:batchCreate`;
const batchedFiles = chunk(files, 50);
// eslint-disable-next-line
for (const batch of batchedFiles) {
// eslint-disable-next-line
const newMediaItems = await Promise.all(
batch.map(async (file) => {
const token = await this.transport.upload(file.name, file.path, requestTimeout);
return {
description: file.description || '',
simpleMediaItem: {
fileName: file.name,
uploadToken: token,
},
};
})
);
this.transport.post(url, {
albumId: albumId || '',
newMediaItems,
});
// google upload token generation seems to cap at ~500 requests per minute, this is a configurable workaround
// eslint-disable-next-line
await new Promise((resolve) => setTimeout(resolve, requestDelay));
}
}
I have a bunch of files across a bunch of directories, so I modified it to support that, would love to see official support