Answer the question
In order to leave comments, you need to log in
How to upload files to firebase with node js?
Hello everyone I am making a
simple application for node practice, and then there was a problem when sending data to firebase
, I have the following question:
When uploading files to Firebase from a node, the file is loaded but does not open, the loader just spins and that's it...
If you click on Create new access token, then everything opens normally)
How to create a token while sending the picture itself? In order not to create it manually, because. I plan to receive this image on the client later)
import bucket from '../firebaseConfig.js'
class FileService {
saveFile(photo) {
try {
const blob = bucket.file(photo.name)
const blobWriter = blob.createWriteStream({
metadata: {
contentType: photo.mimetype,
}
})
blobWriter.on('error', (err) => console.log (err))
blobWriter.end (photo.data)
return photo.name
} catch (e) {
console.log(e);
}
}
}
export default new FileService;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question