I am trying to read an image and text files and upload to aws s3 bucket
using nodejs fs module
. I am not using any express server, but plain javascript that calls aws-sdk and uploads items to aws-s3
.
Here is how my project structure looks like
Inside s3.js I am trying to read the 2.png and friends.json files, s3.js
const fs = require('fs');
const file = fs.readFileSync('../public/2.png', (err)=>console.log(err.message));
But this throw and error
Error: ENOENT: no such file or directory, open '../public/2.png'
What could be going wrong?