Вот мой код. переменная файл в коде
console.log(JSON.stringify(file));
не определена.
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const Buffer = require('buffer').Buffer;
const stream = require('stream');
exports.updateUserInfo = functions.https.onRequest(function(req, res){
const uid = req.params.uid;
const name = req.query.name;
const gender = req.query.gender;
const birthday = req.query.birthday;
const base64Image = req.query.profileImage;
let bufferStream = new stream.PassThrough();
bufferStream.end(new Buffer.from(base64Image, 'base64'));
let bucket = admin.storage().bucket();
let file = bucket.file('user_images/' + uid + '/example.jpg');
bufferStream.pipe(file.createWriteStream({
metadata: {
contentType: 'image/jpeg'
}
}))
.on('error', error => {
console.log("error", error);
})
.on('finish', (file) => {
console.log(JSON.stringify(file));
});
})