I am trying to use package to upload the file into s3 but it is not working as expected , I have tried multiple way's for it but i really can't find any solution,
HTML
<!-- FileUploaderLWC.html -->
<template>
<div>
<input type="file" accept=".pdf,.png,.jpg" onchange={handleFileChange}></input>
</div>
</template>
JS
I have tried placing the debugger but it is not passing the package
import { LightningElement, track } from "lwc";
export default class DocumentManagementHome extends LightningElement {
handleFileChange(event) {
console.log('Hitted')
const file = event.target.files[0];
this.uploadFileToS3(file);
}
uploadFileToS3(file) {
// Use AWS SDK to upload the file to S3 using the generated credentials
// Here you'll need to use the AWS SDK for JavaScript, which can be imported via npm or included as a script tag
// Initialize the AWS SDK with your credentials
console.log('FILE',file)
const AWS = require('aws-sdk');
const s3 = new AWS.S3({
accessKeyId: 'key',
secretAccessKey: 'secret',
});
console.log(s3)
const params = {
Bucket: 'bucketName',
Key: file.name,
Body: file
};
s3.upload(params, (err, data) => {
console.log('Called')
if (err) {
console.error('Error uploading file: ', err);
} else {
console.log('123')
console.log('File uploaded successfully: ', data.Location);
}
});
}
}