Here is my fileUploadService file:
import crypto from 'crypto';
var storage = require('@google-cloud/storage')();
uploadFile(req, bucket, next) {
if (!req.file) {
return next();
}
const gcsname = req.file.originalname;
const file = bucket.file(gcsname);
const stream = file.createWriteStream({
metadata: {
contentType: req.file.mimetype
}
});
stream.on('error', (err) => {
req.file.cloudStorageError = err;
next(err);
});
/*stream.on('finish', () => {
req.file.cloudStorageObject = gcsname;
file.makePublic().then(() => {
req.file.cloudStoragePublicUrl = this.getPublicUrl(gcsname);
next();
});
});*/
stream.end(req.file.buffer);
}
I have to make the file accessible for only sender and receiver. Is there anyway to achieve this?