Check google drive file size

This commit is contained in:
Made Baruna 2021-12-05 23:52:34 +07:00
parent 30fa15e367
commit a0727b0ce6
No known key found for this signature in database
GPG key ID: 5AA5DA16AA5DCEAD

View file

@ -44,7 +44,7 @@
timeout = setTimeout(() => { timeout = setTimeout(() => {
handleError(); handleError();
}, 15000); }, 30000);
} }
function cancelTimeout() { function cancelTimeout() {
@ -291,6 +291,23 @@
async function getData() { async function getData() {
console.log('reading remote file now'); console.log('reading remote file now');
try {
const { result } = await gapi.client.drive.files.get({
fileId: $saveId,
fields: 'size',
});
console.log('drive size', result);
if (result.size > 50000000) {
return {
[UPDATE_TIME_KEY]: dayjs('2000-01-01-00:00'),
};
}
} catch (err) {
console.error('get file size error', err);
handleError();
}
try { try {
const { result } = await gapi.client.drive.files.get({ const { result } = await gapi.client.drive.files.get({
fileId: $saveId, fileId: $saveId,