imageURL:GWM
This commit is contained in:
parent
d7a4af69cf
commit
6a6c188a7f
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,3 +5,4 @@
|
||||
!storage
|
||||
storage/*
|
||||
!storage/uploads/
|
||||
googlrCloud.json
|
||||
@ -10,7 +10,7 @@ module.exports = {
|
||||
"port": process.env.PORT,
|
||||
"host": process.env.HOST,
|
||||
"dialect": "mssql",
|
||||
//"logging": (message) =>(logMsg.info(message))
|
||||
"logging": (message) =>(logMsg.info(message))
|
||||
|
||||
}
|
||||
};
|
||||
@ -3,6 +3,10 @@ const { logMsg } = require('../services/logger.js');
|
||||
const ApiCallHelper = require('../services/apicallhelper.js');
|
||||
const request = require('request');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const {Storage} = require('@google-cloud/storage');
|
||||
|
||||
|
||||
|
||||
exports.PullSalesPdData = async (req, res) =>
|
||||
{
|
||||
@ -435,7 +439,6 @@ exports.imageView = async (req, res) =>
|
||||
const filePath = "storage/uploads/"+req.query.img_name;
|
||||
const { dirname } = require('path');
|
||||
const appDir = dirname(require.main.filename);
|
||||
|
||||
res.sendFile(filePath , { root: appDir });
|
||||
} catch(err) {
|
||||
res.send({'status':404,message: err.message || "Some error occurred while retrieving data." ,'data': "No data" }) ;
|
||||
@ -574,7 +577,7 @@ exports.SectionList = async (req, res) =>
|
||||
pdId = req.query.pd_id;
|
||||
GeneralSection.findAll({ where:{case_no:pdId,is_active : 1},
|
||||
include: [ {model: FundRequirement }, {model: DetailsOfKeyShareHolder }, {model: FinancialInformation }, {model: FinalRemarks }, {model: BriefOfBusiness }, {model: PropertyInformation }, {model: OfficerDetails }, {model: ProductInformation } , {model: InstitutionDetail } , {model: Photograph }] })
|
||||
.then(data =>
|
||||
.then(async(data) =>
|
||||
{
|
||||
|
||||
if(data[0].dataValues.product == 'MEQ')
|
||||
@ -583,9 +586,25 @@ exports.SectionList = async (req, res) =>
|
||||
}else{
|
||||
section_name_obj = {section1_key : "GeneralSection" ,section1_name : "General Section" ,section2_key : "FundRequirements",section2_name : "Fund Requirements",section3_key : "DetailsOfKeyShareHolders",section3_name : "Details Of Key Share Holders",section4_key : "BriefOfBusinesses",section4_name : "Brief Of Businesses",section5_key : "FinancialInformations",section5_name : "Financial Informations",section6_key : "PropertyInformations",section6_name : "Property Informations",section7_key : "FinalRemarks",section7_name : "Final Remarks",section8_key : "OfficerDetails",section8_name : "Officer Details",section9_key : "Photographs",section9_name : "Photographs"};
|
||||
}
|
||||
|
||||
|
||||
if(data.length > 0)
|
||||
{
|
||||
|
||||
if(Array.isArray(data[0].dataValues.Photographs) == true && data[0].dataValues.Photographs.length > 0)
|
||||
{
|
||||
ImageData = [];
|
||||
const storage = new Storage({ keyFilename : path.join(__dirname, "../../googleCloud.json") });
|
||||
const bucketName = 'sales-pd';
|
||||
for(const PhotographsValue of data[0].dataValues.Photographs)
|
||||
{
|
||||
const fileName = 'pd'+PhotographsValue.ref_no+'/images/'+PhotographsValue.img;
|
||||
const options = {version: 'v2', action: 'read',expires: Date.now() + 1000 * 60 * 60, };
|
||||
const [url] = await storage.bucket(bucketName).file(fileName).getSignedUrl(options);
|
||||
|
||||
await ImageData.push( Object.assign(PhotographsValue.dataValues, { url: url }));
|
||||
}
|
||||
Object.assign(data[0], {Photographs:ImageData})
|
||||
}
|
||||
res_data = {data : data , section_names : section_name_obj}
|
||||
res.send({'status':200,'message':"success",'data':res_data});
|
||||
}
|
||||
@ -1066,4 +1085,48 @@ exports.ReInsertImageData = async (req, res) =>
|
||||
res.send({'status':404,message: err.message || "Some error occurred while retrieving data." ,'data': "No data" });
|
||||
} //end of try catch
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
exports.downloadFile = async (req, res) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
const storage = new Storage({ keyFilename : path.join(__dirname, "../../googleCloud.json") });
|
||||
|
||||
// downloas file ***********************
|
||||
// const bucketName = 'sales-pd';
|
||||
// const srcFilename = 'pd2968/images/1676975188920-temp02023-02-21_03-56-27.png';
|
||||
// const destFilename = '1676975188920-temp02023-02-21_03-56-27.png';
|
||||
// const options = {destination: destFilename,};
|
||||
// await storage.bucket(bucketName).file(srcFilename).download(options);
|
||||
|
||||
// console.log(
|
||||
// "The object " + srcFilename +
|
||||
// " coming from bucket " + bucketName +
|
||||
// " has been downloaded to " + destFilename
|
||||
// );
|
||||
// downloas file ***********************
|
||||
|
||||
// create url ***********************
|
||||
// const bucketName = 'sales-pd';
|
||||
// const fileName = 'pd2968/images/1676975188920-temp02023-02-21_03-56-27.png';
|
||||
// const options = {
|
||||
// version: 'v2', // defaults to 'v2' if missing.
|
||||
// action: 'read',
|
||||
// expires: Date.now() + 1000 * 60 * 60, // one hour
|
||||
// };
|
||||
// const [url] = await storage.bucket(bucketName).file(fileName).getSignedUrl(options);
|
||||
// console.log(`The signed url for ${fileName} is ${url}.`);
|
||||
// create url ***********************
|
||||
|
||||
} catch(err) {
|
||||
res.send({'status':404,message: err.message || "Some error occurred while retrieving data." ,'data': "No data" });
|
||||
} //end of try catch
|
||||
|
||||
};
|
||||
@ -7,6 +7,7 @@ module.exports = app => {
|
||||
var router = require("express").Router();
|
||||
router.post('/PullSalesPdshareholderData',SalesPdController.PullSalesPdshareholderData);
|
||||
router.post('/ReInsertImageData',SalesPdController.ReInsertImageData);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/demo:
|
||||
|
||||
5431
package-lock.json
generated
5431
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -22,7 +22,8 @@
|
||||
"swagger-jsdoc": "^6.1.0",
|
||||
"swagger-ui-express": "^4.1.6",
|
||||
"winston": "^3.3.3",
|
||||
"winston-daily-rotate-file": "^4.5.5"
|
||||
"winston-daily-rotate-file": "^4.5.5",
|
||||
"@google-cloud/storage": "^6.9.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^2.0.12"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user