I have a quick question. I would like to extract the file name of a wav file I am passing to my backend through axios using formData. I am not sure how to do this is nodejs. I would appreciate any help
Frontend:
//file is a Blob
var new_file = new File([file], bucket_string);
var formData = new FormData();
formData.append("wavfile", new_file, bucket_string);
const config = {
headers: { 'content-type': 'multipart/form-data' }
}
return await axios.post(`/files/upload-file`, formData, config);
//return await axios.post(`http://localhost:2000/files/upload-file`, data);
backend:
controller.js
async function uploadFile(req, res, next) {
fileService.uploadFile().then(function(val) {
res.json(val)
});
}
service.js
function uploadFile({ data }) {
const file = data;
var file_name = ?
//i would like to get the file name here
}