Agregue exension a la base de datos
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 129 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 129 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 129 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 86 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 998 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 998 KiB |
@@ -6,9 +6,9 @@ const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
const ticket = async (body) => {
|
||||
return Inscripcion.findOne({
|
||||
where: { folio: body.folio },
|
||||
attributes: ['rutaTicket'],
|
||||
attributes: ['rutaTicket', 'extension'],
|
||||
}).then((res) => {
|
||||
return res.rutaTicket;
|
||||
return { rutaTicket: res.rutaTicket, extension: res.extension };
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ const inscripcion = async (body, file) => {
|
||||
fechaInscripcion: ahora.format(),
|
||||
fechaTicket: body.fechaTicket,
|
||||
rutaTicket: file.path,
|
||||
extension: file.mimetype.split('/')[1],
|
||||
});
|
||||
} else {
|
||||
return Inscripcion.create({
|
||||
|
||||
@@ -50,6 +50,10 @@ Inscripcion.init(
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
},
|
||||
extension: {
|
||||
type: DataTypes.STRING(6),
|
||||
allowNull: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
|
||||
@@ -34,7 +34,10 @@ 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);
|
||||
console.log(data);
|
||||
fs.createReadStream(
|
||||
process.cwd() + '/' + data.rutaTicket + '.' + data.extension
|
||||
).pipe(res);
|
||||
// res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
|
||||
Reference in New Issue
Block a user