aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Powers <mark@marks.kitchen>2019-11-05 01:20:56 +0000
committerMark Powers <mark@marks.kitchen>2019-11-05 01:20:56 +0000
commit22cf43731ccae151b1fddc80a47b30b8f943a481 (patch)
tree0eb862b8ce560a581ec7e8b510b5dae596add965
parent5c138373b366547190fbc655c19a25a7a7ab4996 (diff)
Fix uploading, uses full path now
-rw-r--r--package-lock.json4
-rw-r--r--src/server.js5
2 files changed, 5 insertions, 4 deletions
diff --git a/package-lock.json b/package-lock.json
index 93074c6..68d4843 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -56,7 +56,7 @@
},
"array-flatten": {
"version": "1.1.1",
- "resolved": "http://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
+ "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
},
"asn1": {
@@ -676,7 +676,7 @@
},
"media-typer": {
"version": "0.3.0",
- "resolved": "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
+ "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
},
"merge-descriptors": {
diff --git a/src/server.js b/src/server.js
index a735d35..1bbac30 100644
--- a/src/server.js
+++ b/src/server.js
@@ -4,13 +4,14 @@ const cookieParser = require('cookie-parser');
const request = require('request');
const crypto = require('crypto');
const uuidv4 = require('uuid/v4');
+const path = require('path');
const Op = require('sequelize').Op;
const multer = require('multer');
var storage = multer.diskStorage({
destination: function (req, file, cb) {
- cb(null, 'src/uploads/')
+ cb(null, __dirname+'/uploads/')
},
filename: function (req, file, cb) {
var ext = "";
@@ -160,7 +161,7 @@ function setUpRoutes(models, jwtFunctions, database) {
try {
const type = req.body.type
const newPost = await models.posts.create(req.body);
- req.files.forEach(async (file) => {
+ req.files.forEach(async (file) => {
await models.pictures.create({ "source": "uploads/" + file.filename, "postId": newPost.id });
console.log("uploaded ", file.path);
})