This commit is contained in:
suseendhiran17 2023-07-14 10:42:51 +05:30
parent 64e4a5f661
commit ec8ed85210
2 changed files with 19 additions and 2 deletions

View File

@ -1141,4 +1141,21 @@ const storage = new Storage({ keyFilename : path.join(__dirname, "../../googleCl
res.send({'status':404,message: err.message || "Some error occurred while retrieving data." ,'data': "No data" });
} //end of try catch
};
};
exports.test = async (req, res) => {
const storage = new Storage({ keyFilename : path.join(__dirname, "../../googleCloud.json") });
bucketName = 'pd-giene-data';
const bucket = storage.bucket(bucketName);
try {
const [files] = await bucket.getFiles();
const fileNames = files.map((file) => file.name);
console.log('File names:', fileNames);
res.send({'data':fileNames})
} catch (error) {
console.error('Error retrieving file names:', error);
}
}

View File

@ -19,7 +19,7 @@ module.exports = app => {
* description: success
*/
router.get("/demo", Mycontroller.Welcome);
router.get("/test", SalesPdController.test);
// landing page api
/**
* @swagger