guardamos y emitimos la imagen

This commit is contained in:
Andres2908
2022-02-03 23:09:40 -06:00
parent 83cbd46bc3
commit 0710ee28ee
8 changed files with 31 additions and 2 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 998 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 998 KiB

+15
View File
@@ -0,0 +1,15 @@
// const validar = require('../../../helper/validar');
const dbPath = '../../db/tablas';
const Usuario = require(`${dbPath}/Usuario`);
const Inscripcion = require(`${dbPath}/Inscripcion`);
const ticket = async (body) => {
return Inscripcion.findOne({
where: { folio: body.folio },
attributes: ['rutaTicket'],
}).then((res) => {
return res.rutaTicket;
});
};
module.exports = ticket;
@@ -8,7 +8,7 @@ const todasInscripciones = async (body) => {
include: [
{
model: Usuario,
attributes: ['numeroCuenta'],
attributes: ['idUsuario', 'numeroCuenta'],
},
],
});
+14
View File
@@ -1,5 +1,7 @@
const express = require('express');
const ticket = require('../controller/Admin/ticket');
const app = express();
const fs = require('fs');
const route = '/Admin';
const controllerPath = '../controller/Admin';
const todasInscripciones = require(`${controllerPath}/todasInscripciones`);
@@ -14,4 +16,16 @@ app.get(`${route}/todas_inscripciones`, (req, res) => {
});
});
app.get(`${route}/ticket`, (req, res) => {
return ticket(req.query)
.then((data) => {
res.writeHead(200, { 'content-type': `image/png` });
fs.createReadStream(process.cwd() + '/' + data + '.jpeg').pipe(res);
// res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
module.exports = app;
+1 -1
View File
@@ -2,7 +2,7 @@ const express = require('express');
const app = express();
const fs = require('fs');
const multer = require('multer');
const upload = multer({ dest: 'tickets/images' });
const upload = multer({ dest: 'images' });
const { verificaToken } = require('../middleware/autentificacion');
const route = '/Usuario';
const controllerPath = '../controller/Usuario';