hidjou / classsed-react-firebase-functions

327 stars 180 forks source link

user/image upload not working. Shows bad request while trying to upload #1

Open ShrawanBK opened 5 years ago

ShrawanBK commented 5 years ago

The code shows console log until busboy.on('file') but not in busboy.on('finish'). Help needed !!

Hewlbern commented 4 years ago

same issue

karan-vk commented 4 years ago

explicitly add the storage bucket in the admin initialization

davigsa commented 4 years ago

I had the same problem. I didnt specify my collection correctly. So a did this: Change this

        .then(() => {
            const imageUrl = `https://firebasestorage.googleapis.com/v0/b/${config.storageBucket}/o/${imageFileName}?alt=media`;
            return admin.firestore().doc(`/users/${req.user.handle`).update({ imageUrl });
        })

for this

        .then(() => {
            const imageUrl = `https://firebasestorage.googleapis.com/v0/b/${config.storageBucket}/o/${imageFileName}?alt=media`;
            return admin.firestore().collection('users').doc(`${req.user.handle}`).update({ imageUrl });
        })

I hope my answer helps anyone 🤓

ironspur5 commented 4 years ago

Same issue, I get Internal Server Error in Postman. @davigsa fix did not work for me. On admin, also added the specific storage bucket as some other users have suggested (.bucket(${config.storageBucket}). No luck there either. Any ideas?

likwid23 commented 3 years ago

I get this error on image upload:

TypeError: Cannot read property 'handle' of undefined in this line:

return admin.firestore().doc(/users/${req.user.handle).update({ imageUrl });