cloud upload files
71
package-lock.json
generated
@@ -12,6 +12,7 @@
|
||||
"axios": "^0.26.0",
|
||||
"ejs": "^3.0.2",
|
||||
"express": "^4.17.1",
|
||||
"express-fileupload": "^1.3.1",
|
||||
"express-myconnection": "^1.0.4",
|
||||
"morgan": "^1.10.0",
|
||||
"mysql": "^2.18.1",
|
||||
@@ -189,6 +190,17 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/busboy": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/busboy/-/busboy-0.3.1.tgz",
|
||||
"integrity": "sha512-y7tTxhGKXcyBxRKAni+awqx8uqaJKrSFSNFSeRG5CsWNdmy2BIK+6VGWEW7TZnIO/533mtMEA4rOevQV815YJw==",
|
||||
"dependencies": {
|
||||
"dicer": "0.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/bytes": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
|
||||
@@ -402,6 +414,17 @@
|
||||
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
|
||||
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
|
||||
},
|
||||
"node_modules/dicer": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/dicer/-/dicer-0.3.0.tgz",
|
||||
"integrity": "sha512-MdceRRWqltEG2dZqO769g27N/3PXfcKl04VhYnBlo2YhH7zPi88VebsjTKclaOyiuMaGU72hTfw3VkUitGcVCA==",
|
||||
"dependencies": {
|
||||
"streamsearch": "0.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/dot-prop": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.0.tgz",
|
||||
@@ -521,6 +544,17 @@
|
||||
"node": ">= 0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/express-fileupload": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/express-fileupload/-/express-fileupload-1.3.1.tgz",
|
||||
"integrity": "sha512-LD1yabD3exmWIFujKGDnT1rmxSomaqQSlUvzIsrA1ZgwCJ6ci7lg2YHFGM3Q6DfK+Yk0gAVU7GWLE7qDMwZLkw==",
|
||||
"dependencies": {
|
||||
"busboy": "^0.3.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/express-myconnection": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/express-myconnection/-/express-myconnection-1.0.4.tgz",
|
||||
@@ -1487,6 +1521,14 @@
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/streamsearch": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz",
|
||||
"integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=",
|
||||
"engines": {
|
||||
"node": ">=0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
@@ -1934,6 +1976,14 @@
|
||||
"fill-range": "^7.0.1"
|
||||
}
|
||||
},
|
||||
"busboy": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/busboy/-/busboy-0.3.1.tgz",
|
||||
"integrity": "sha512-y7tTxhGKXcyBxRKAni+awqx8uqaJKrSFSNFSeRG5CsWNdmy2BIK+6VGWEW7TZnIO/533mtMEA4rOevQV815YJw==",
|
||||
"requires": {
|
||||
"dicer": "0.3.0"
|
||||
}
|
||||
},
|
||||
"bytes": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
|
||||
@@ -2103,6 +2153,14 @@
|
||||
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
|
||||
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
|
||||
},
|
||||
"dicer": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/dicer/-/dicer-0.3.0.tgz",
|
||||
"integrity": "sha512-MdceRRWqltEG2dZqO769g27N/3PXfcKl04VhYnBlo2YhH7zPi88VebsjTKclaOyiuMaGU72hTfw3VkUitGcVCA==",
|
||||
"requires": {
|
||||
"streamsearch": "0.1.2"
|
||||
}
|
||||
},
|
||||
"dot-prop": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.0.tgz",
|
||||
@@ -2201,6 +2259,14 @@
|
||||
"vary": "~1.1.2"
|
||||
}
|
||||
},
|
||||
"express-fileupload": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/express-fileupload/-/express-fileupload-1.3.1.tgz",
|
||||
"integrity": "sha512-LD1yabD3exmWIFujKGDnT1rmxSomaqQSlUvzIsrA1ZgwCJ6ci7lg2YHFGM3Q6DfK+Yk0gAVU7GWLE7qDMwZLkw==",
|
||||
"requires": {
|
||||
"busboy": "^0.3.1"
|
||||
}
|
||||
},
|
||||
"express-myconnection": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/express-myconnection/-/express-myconnection-1.0.4.tgz",
|
||||
@@ -2931,6 +2997,11 @@
|
||||
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
|
||||
"integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
|
||||
},
|
||||
"streamsearch": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz",
|
||||
"integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo="
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"axios": "^0.26.0",
|
||||
"ejs": "^3.0.2",
|
||||
"express": "^4.17.1",
|
||||
"express-fileupload": "^1.3.1",
|
||||
"express-myconnection": "^1.0.4",
|
||||
"morgan": "^1.10.0",
|
||||
"mysql": "^2.18.1",
|
||||
|
||||
@@ -2,6 +2,7 @@ const express = require('express');
|
||||
const path = require('path');
|
||||
const morgan = require('morgan');
|
||||
const mysql = require('mysql');
|
||||
const cloud_file = require('express-fileupload');
|
||||
const myConecction = require('express-myconnection');
|
||||
|
||||
var puerto = 3001
|
||||
@@ -11,6 +12,7 @@ const app = express();
|
||||
const clientesRutas = require('./rutas/rt_clientes');
|
||||
const productosRutas = require('./rutas/rt_items');
|
||||
const generalesRutas = require('./rutas/rt_Generales');
|
||||
const cloud_rutas = require('./rutas/rt_cloud');
|
||||
|
||||
//configuraciones
|
||||
app.set('port',process.env.PORT||puerto);
|
||||
@@ -19,6 +21,7 @@ app.set('views',path.join(__dirname, 'views'));
|
||||
//app.set('vistas',path.join(__dirname, 'vistas'));
|
||||
|
||||
//middlewares
|
||||
|
||||
app.use(morgan('dev'));
|
||||
app.use(myConecction(mysql,{
|
||||
//host:'192.168.10.50',
|
||||
@@ -31,11 +34,17 @@ app.use(myConecction(mysql,{
|
||||
//cuando reciba dato desde req body
|
||||
app.use(express.json({limit: '25mb'}));
|
||||
app.use(express.urlencoded({limit:'25mb',extended:false}));
|
||||
//
|
||||
//app.use(cloud_file);
|
||||
app.use(cloud_file({
|
||||
limits: { fileSize: 50 * 1024 * 1024 },
|
||||
}));
|
||||
|
||||
//rutas
|
||||
app.use('/', clientesRutas);
|
||||
app.use('/', productosRutas);
|
||||
app.use('/', generalesRutas);
|
||||
app.use('/', cloud_rutas);
|
||||
|
||||
//prueba de json directa
|
||||
app.get('/pruebaJson',function(req,res){
|
||||
|
||||
@@ -80,10 +80,4 @@ controlador.verVentasJson = (req, res) => {
|
||||
res.render('panel_control');
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
module.exports = controlador;
|
||||
|
||||
45
src/controladores/controlador_cloud.js
Normal file
@@ -0,0 +1,45 @@
|
||||
const controlador={};
|
||||
const dirPath = "/home/pablinux/Projects/Node/APP-SIGMA-WEB/src/public/files/";
|
||||
//********* APP-panel control ********//
|
||||
controlador.upload = (req, res) => {
|
||||
if(!req.files||Object.keys(req.files).lenght===0){
|
||||
return res.status(400).send({message:'archivos no cargados'});
|
||||
}else{
|
||||
const file = req.files.file_toUpload;
|
||||
const path = dirPath + file.name;
|
||||
console.log(path);
|
||||
file.mv(path, (err) => {
|
||||
if (err) {
|
||||
return res.status(500).send(err);
|
||||
}
|
||||
return res.send({ status: "success", path: path });
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//ruta actual
|
||||
const procesarPath = (path) => {
|
||||
return path ? path.replace(/-/g,'/'):'/';
|
||||
}
|
||||
|
||||
const fs = require('fs');
|
||||
function leer_dir(dir){
|
||||
var json = [];
|
||||
var files = fs.readdirSync(dirPath);
|
||||
files.forEach(function(arch,idx){
|
||||
json.push({"indice": idx, "archivo": arch});
|
||||
});
|
||||
//console.log(json);
|
||||
return json;
|
||||
}
|
||||
|
||||
controlador.ver_dirActual = (req, res) => {
|
||||
let dir = procesarPath(req.params.path);
|
||||
var files = leer_dir("files");
|
||||
//res.render('cloud');
|
||||
res.render('cloud',{
|
||||
data:files
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = controlador;
|
||||
17
src/public/css/cloud.css
Normal file
@@ -0,0 +1,17 @@
|
||||
body{
|
||||
background:rgb(10, 10, 10);
|
||||
color: rgb(255, 255, 255);
|
||||
}
|
||||
.files{
|
||||
background: rgba(100, 100, 100, 0.5);
|
||||
margin: 10px;
|
||||
padding: 5px;
|
||||
}
|
||||
.info{
|
||||
font-family: sigma_font;
|
||||
font-size: 20px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
.upload{
|
||||
margin: 2px;
|
||||
}
|
||||
BIN
src/public/etiquetas/bar_generado.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
10
src/public/etiquetas/error.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" dir="ltr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Error</h1>
|
||||
</body>
|
||||
</html>
|
||||
57
src/public/etiquetas/etiquetas_bar.html
Normal file
@@ -0,0 +1,57 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="es" dir="ltr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
<style type="text/css">
|
||||
body{
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
.etiqueta{
|
||||
background: rgb(255, 255, 255);
|
||||
width: 34mm;
|
||||
height: 25mm;
|
||||
}
|
||||
.titulo{
|
||||
text-align: center;
|
||||
}
|
||||
.codigo{
|
||||
align-items: center;
|
||||
}
|
||||
.codigo img{
|
||||
display:block;
|
||||
margin:auto;
|
||||
}
|
||||
.precio{
|
||||
display: flex;
|
||||
font-size: 18px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
.p1{
|
||||
left: 0px;
|
||||
margin: auto;
|
||||
font-weight: bold;
|
||||
}
|
||||
.p2{
|
||||
right: 0px;
|
||||
margin: auto;
|
||||
}
|
||||
/*1mm = 3,779 527 559 055 1 Pixel [px]
|
||||
34mm = 128px
|
||||
25mm = 94px
|
||||
*/
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="etiqueta">
|
||||
<div class="titulo">Nombre Producto</div>
|
||||
<div class="codigo">
|
||||
<img src="bar_generado.png" alt="Codigo Barra" height="48" width="96"/>
|
||||
</div>
|
||||
<div class="precio">
|
||||
<div class="p1"> $15.23</div>
|
||||
<div class="p2"> $15.23</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
48
src/public/etiquetas/etiquetas_qr.html
Normal file
@@ -0,0 +1,48 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="es" dir="ltr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
<style type="text/css">
|
||||
body{
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
.etiqueta{
|
||||
padding-top: 3px;
|
||||
background: rgb(255, 255, 255);
|
||||
width: 34mm;
|
||||
height: 25mm;
|
||||
}
|
||||
.titulo{
|
||||
text-align: center;
|
||||
}
|
||||
.codigo{
|
||||
}
|
||||
.p1{
|
||||
margin-top: 10px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.p2{
|
||||
margin-top: 10px;
|
||||
}
|
||||
.row{
|
||||
display: flex;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="etiqueta">
|
||||
<div class="titulo">Nombre Producto</div>
|
||||
<div class="row">
|
||||
<div class="codigo">
|
||||
<img src="qr_generado.png" alt="Codigo Barra" height="70" width="70"/>
|
||||
</div>
|
||||
<div class="precio">
|
||||
<div class="p1"> $15.23</div>
|
||||
<div class="p2"> $15.23</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
BIN
src/public/etiquetas/qr_generado.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
src/public/files/2012-09-22 23.53.11.jpg
Normal file
|
After Width: | Height: | Size: 1.2 MiB |
BIN
src/public/files/20171001_125137.jpg
Normal file
|
After Width: | Height: | Size: 4.1 MiB |
BIN
src/public/files/9D49862B-898E-4394-BD7F-00BC4DA6A66A.jpg
Normal file
|
After Width: | Height: | Size: 270 KiB |
BIN
src/public/files/SIGMA-X.tar.gz
Normal file
BIN
src/public/files/cb1c9f62-d86e-4ad6-92de-320d9c4a3aa6.jpeg
Normal file
|
After Width: | Height: | Size: 96 KiB |
BIN
src/public/files/ndb-battery-1.jpg
Normal file
|
After Width: | Height: | Size: 40 KiB |
@@ -10,6 +10,4 @@ rutas.get('/gp_precios', controlador_init.app_GpPrecios);//consulta grupo precio
|
||||
rutas.get('/origen_pedidos', controlador_init.app_ORIGENES);//consulta grupo precios
|
||||
rutas.get('/panel_control', controlador_init.panel_control);//consulta grupo precios
|
||||
|
||||
|
||||
|
||||
module.exports = rutas;
|
||||
|
||||
9
src/rutas/rt_cloud.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const express = require('express');
|
||||
const rutas = express.Router();
|
||||
|
||||
const controlador_cloud = require('../controladores/controlador_cloud');
|
||||
//para cargar archivos
|
||||
rutas.post('/upload', controlador_cloud.upload);//ver productos en modo json/get
|
||||
rutas.get('/cloud/', controlador_cloud.ver_dirActual);//ver productos en modo json/get
|
||||
|
||||
module.exports = rutas;
|
||||
50
src/views/cloud.ejs
Normal file
@@ -0,0 +1,50 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Cloud SIGMA</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
|
||||
<link href="./css/tipografias.css" rel="stylesheet" type="text/css"/>
|
||||
<link href="./css/cloud.css" rel="stylesheet" type="text/css"/>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">
|
||||
<img src="img/favicon_sigma/android-chrome-192x192.png" alt="" width="36" height="36"></a>
|
||||
<form class="d-flex">
|
||||
<input class="form-control me-2" type="search" placeholder="Buscar Archivo" aria-label="Search">
|
||||
<button class="btn btn-outline-success" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- formulario para subir archivos --->
|
||||
</br>
|
||||
<div class="row upload">
|
||||
<label for="basic-url" class="form-label info">SIGMA Cloud</label>
|
||||
<form class="d-flex" method="POST" action="/upload" enctype="multipart/form-data">
|
||||
<div class="input-group mb-3">
|
||||
<input type="file" name="file_toUpload" class="form-control"/>
|
||||
<input type="submit" class="btn btn-outline-secondary"/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<!-- formulario para subir archivos --->
|
||||
</br>
|
||||
<div class="row mb-3 files">
|
||||
<div><a href="">.. retornar</a></div>
|
||||
<% for (i in data) { %>
|
||||
<div>
|
||||
<span>#<%= data[i].indice%> </span>
|
||||
<a href=""><%= data[i].archivo%></a>
|
||||
</div>
|
||||
</br>
|
||||
<% } %>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var files=[];
|
||||
files = <%= data %>;
|
||||
console.log(data);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||