rowanwins / vue-dropzone

A Vue.js component for Dropzone.js - a drag’n’drop file uploads utility with image previews
https://rowanwins.github.io/vue-dropzone/docs/dist
MIT License
2.02k stars 1.4k forks source link

how to access the key returned from amazon after uploading #615

Open ibrahem-kamal opened 2 years ago

ibrahem-kamal commented 2 years ago

i need to get the key returned from amazon after uploading the file but i can see that u only return the file location in the payload

level09 commented 2 years ago

You can get it form the files, they will have an xhr object containing the response in XML format, you only need to parse that

const f = app.$refs.dropzone.getAcceptedFiles()[0];
const parser = new DOMParser();
const awsRes = parser.parseFromString(f.xhr.response,'text/xml');

console.log(awsRes.getElementsByTagName('Location')[0].innerHTML); // <- this is your s3 locaiton
console.log(awsRes.getElementsByTagName('ETag')[0].innerHTML); // <- this is your ETag