My upload.js file contains the following code:
module.exports = {
up: function () {
const storage = require('@google-cloud/storage');
const fs = require('fs');
const gcs = storage({
projectId: 'MY_PROJECT_ID',
keyFilename: './service-account.json'
});
var bucket = gcs.bucket('MY_BUCKET');
bucket.upload('picture.jpg', function(err, file) {
if (err) throw new Error(err);
});
},
}
It works through the terminal but how do I call it on form submission button click or just from different file ?
When I try it gives me:
Cannot read property 'prototype' of undefined
I'm quite new to NodeJs and I don't really know what to do.
Google documentation doesn't help me at all unfortunately :/