I am trying to access my s3 bucket and show the photos in my angular using the syncfusion file manager.
in my TypeScript file:
ajaxSettings:any;
public hostUrl: string = 'http://localhost:3000/';
constructor() { }
ngOnInit() {
this.ajaxSettings = {
url: this.hostUrl + 'api/v1/upload/'
in my html:
<ejs-filemanager id='default-filemanager' [ajaxSettings]='ajaxSettings'></ejs-filemanager>
and here is my server.js in my NodeJS API:
app.use(bodyParser.json());
app.use(cors());
app.post('/api/v1/upload/', upload.array('image', 1), (req, res) => {
res.send({ image: req.file });
});
const PORT = process.env.PORT || 3000;
app.listen(3000, () => {
console.log(`server started on port 3000`);
});
and I have a JS file for uploading photos to AWS S3:
aws.config.update({
secretAccessKey: process.env.ACCESS_KEY_ID,
accessKeyId: process.env.SECRET_ACCESS_KEY,
region: 'ap-south-1'
});
const s3 = new aws.S3();
const upload = multer({
storage: multerS3({
acl: 'public-read',
s3,
bucket: 'angular-upload-files-2023-2024',
key: function(req, file, cb) {
req.file = file.originalname;
//include the folder created before uploading files...
cb(null, "properties2023/" + file.originalname);
}
})
});
module.exports = upload;
I am struggling how to connect to S3 bucket from my html going through my NodeJS?
<ejs-filemanager id='default-filemanager' [ajaxSettings]='ajaxSettings'></ejs-filemanager>
I have looked at the syncfusion documents but couldn't find the way?
How to process the request to make API connect to the AWS S3 bucket?