When I use an npm package like google-cloud or multer-gcs to upload a file to firebase storage bucket (that uses google cloud storage under the hood..) the file gets uploaded. However, the file does not show and image type(MIME). Also, how do I use the image in my node.js application?
Here is the code to upload image to firebase bucket. Used multer to handle file upload..
var path = require('path');
var multer = require('multer');
var gcs = require( 'multer-gcs' );
var storage = gcs({
filename : function( req, file, cb ) {
cb( null, file.fieldname + '-' + Date.now() + path.extname(file.originalname).toLowerCase());
},
bucket : 'p****n-bcXX3.appspot.com', // Required : bucket name to upload
projectId : 'p****n-bcXX3', // Required : Google project ID
keyFilename: './p****n-5cbc725XXXXd.json', // Required : JSON credentials file for Google Cloud Storage
acl : 'publicread' // Optional : Defaults to private
});
In my routes:
router.post('/food/create', [authChecker, gcsUpload.single('food_image')], function(req, res, next) {
Controllers.create_food(req, res);
});
When I upload file directly to the bucket, type shows clearly. What's the catch here?
