I am trying to use Google Drive API v3 to get a files blob and then upload it to firebase storage.
drive.files.get({
fileId: fileId,
alt: 'media',
}, {responseType: 'blob'})
.then(response => {
console.log(response.data);
const file = response.data
const storage = getStorage();
const storageRef = ref(storage, 'testvideo.mp4');
// 'file' comes from the Blob or File API
uploadBytes(storageRef, file).then((snapshot) => {
console.log('Uploaded a blob!');
});
})
.catch(err=>{ console.log(err); });
// console.log(response.data) output
Blob {
[Symbol(type)]: 'video/mp4',
[Symbol(buffer)]: <Buffer 00 00 00 18 66 74 79 70 6d 70 34 32 00 00 00 00 69 73 6f 6d 6d 70 34 32 00 00 00 88 66 72 65 65 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 20233366 more bytes>
}
I am having trouble taking the blob in json and using it in nodejs and getting this error at uploadBytes(storageRef, file).
TypeError: Cannot read properties of undefined (reading 'byteLength')
because just result.data isn't a valid blob. Essentially, I'm trying to figure out how to set
const file = new Blob([response.data.buffer], {type: response.data.type});