@ -175,12 +175,16 @@ app.post('/image', uploadMulter.single('image'), async (req, res) => {
const currentDate = new Date ( ) . toISOString ( ) ;
const localFile = reqFile . path . startsWith ( uploadDir + '/' ) ? reqFile . path . substring ( uploadDir . length + 1 ) : reqFile . path ;
const finalUrl = ` https:// ${ imageServer } / ${ fileName } ` ;
const claimType = req . body . claimType ;
const handleId = req . body . handleId ;
await new Promise ( ( resolve , reject ) => {
db . run (
'INSERT INTO image (time, did, local_file, size, final_file, url) VALUES (?, ?, ?, ?, ?, ?)' ,
'INSERT INTO image (time, did, claim_type, handle_id, local_file, size, final_file, url) VALUES (?, ?, ?, ?, ?, ?, ?, ?)' ,
[
currentDate ,
issuerDid ,
claimType ,
handleId ,
localFile ,
reqFile . size ,
fileName ,
@ -272,6 +276,7 @@ app.delete('/image/:url', async (req, res) => {
) ;
} ) ;
if ( ! thisUserImageFile ) {
console . log ( 'No image entry found for user' , issuerDid , '& URL' , url , 'so returning 404.' ) ;
return res . status ( 404 ) . send ( JSON . stringify ( { success : false , message : 'No image entry found for user ' + issuerDid + ' & URL ' + url } ) ) ;
}
@ -282,7 +287,7 @@ app.delete('/image/:url', async (req, res) => {
[ url , issuerDid ] ,
( dbErr , row ) => {
if ( dbErr ) {
console . error ( currentDate , 'Error getting image for user from database:' , dbErr )
console . error ( currentDate , 'Error getting image for other users from database:' , dbErr )
reject ( dbErr ) ;
}
resolve ( row ? . did ) ;