Question: record audio and upload to S3 #3002
-
I'm using the wavesurfer.js library and its record plugin for a vuejs project. I'm using the record plugin to create a voice message. I would like to be able to retrieve the blob of the audio file and upload it to my Amazon S3 server. After a lot of research, I've managed to create this code, but I can't figure out how I can retrieve the audio file created by the record plugin and upload it to the server. What do I need to do?
I tried this... apparently wavesurfer.js returns a URL in blob format. I then injected it into the upload but the webm file generated doesn't contain the audio stream: it contains the blob's text-format url.
I then tried to transform the content into a binary, but I couldn't generate the audio file (it wouldn't play).
I also tried the function below. I wasn't able to test it properly because I couldn't find a way to access the video buffer to generate a wave file. I think I've tried everything:
I'd be really happy if someone could help me. I'm new to vuejs: I started last night. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You should first download the recorded URL and only then upload it to S3. E.g.: record.on('stopRecording', () => {
const blobUrl = record.getRecordedUrl()
fetch(blobUrl)
.then(response => response.blob())
.then(blob => {
// Create params for S3 upload
const uploadParams = {
Bucket: 'YOUR_BUCKET_NAME',
Key: 'your_file_name_here', // replace with your desired file name
Body: blob,
ACL: 'public-read' // if you want the file to be readable publicly
};
// Call S3 to retrieve upload file to specified bucket
s3.upload(uploadParams, (err, data) => { ... })
})
}) |
Beta Was this translation helpful? Give feedback.
You should first download the recorded URL and only then upload it to S3. E.g.: