Fix file uploads in Chrome.

This commit is contained in:
Roger Braun 2017-01-20 23:58:58 +01:00
parent 1a5ec7484e
commit 51473f0484

View File

@ -20,12 +20,23 @@ const uploadMedia = ({ store, formData }) => {
const credentials = store.state.users.currentUser.credentials
return apiService.uploadMedia({ credentials, formData }).then((xml) => {
return {
// Firefox and Chrome treat method differently...
let link = xml.getElementsByTagName('link')
if (link.length === 0) {
link = xml.getElementsByTagName('atom:link')
}
link = link[0]
const mediaData = {
id: xml.getElementsByTagName('media_id')[0].textContent,
url: xml.getElementsByTagName('media_url')[0].textContent,
image: xml.getElementsByTagName('atom:link')[0].getAttribute('href'),
mimetype: xml.getElementsByTagName('atom:link')[0].getAttribute('type')
image: link.getAttribute('href'),
mimetype: link.getAttribute('type')
}
return mediaData
})
}