1

I'm uploading files from Angular 2 with ngx-uploader and storing them on backend (nodejs/feathers) with multer. Now I'm having trouble to reach and display them, for now im just trying to display image, but actually i just need to see how paths work so i can reach the .pdf files. As a file path im getting this: resources\\uploads\\quality-docs\\FILENAME so i tried to reach them like this: http://localhost:3030/resources/uploads/quality-docs/FILENAME but it doesnt work, it gives me 404. Just realised when i put files in static, public folder, i can reach it like http://localhost:3030/FILENAME ... but is there a way for it to not be in public?

This is how my backend structure looks like:

Any ideas/sugestions are welcome, is this even a right way to go? Plus if any of you have idea how to delete files from server?

Kerim092
  • 1,367
  • 1
  • 12
  • 32
  • 1
    Are you using express as your web server on node.js? If so, take a look at http://expressjs.com/en/starter/static-files.html to add a new static route to the resources/uploads directory. – M. Laing Dec 20 '17 at 00:51
  • 1
    Also, to delete the files use `unlink` https://stackoverflow.com/questions/5315138/node-js-remove-file – M. Laing Dec 20 '17 at 00:52
  • wow thanks a lot pal! – Kerim092 Dec 20 '17 at 00:55

1 Answers1

2

Assuming that you are using express in your node app, you need to include a static route to the resources/uploads directory (express static routes) like the following:

app.use(express.static('resources/uploads'))

For deleting files from a node application use unlink fs.unlink

M. Laing
  • 1,607
  • 11
  • 25