Fix file uploads in Chrome.
This commit is contained in:
parent
e81b3ea245
commit
b98a6fe5bc
1 changed files with 14 additions and 3 deletions
|
@ -20,12 +20,23 @@ const uploadMedia = ({ store, formData }) => {
|
||||||
const credentials = store.state.users.currentUser.credentials
|
const credentials = store.state.users.currentUser.credentials
|
||||||
|
|
||||||
return apiService.uploadMedia({ credentials, formData }).then((xml) => {
|
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,
|
id: xml.getElementsByTagName('media_id')[0].textContent,
|
||||||
url: xml.getElementsByTagName('media_url')[0].textContent,
|
url: xml.getElementsByTagName('media_url')[0].textContent,
|
||||||
image: xml.getElementsByTagName('atom:link')[0].getAttribute('href'),
|
image: link.getAttribute('href'),
|
||||||
mimetype: xml.getElementsByTagName('atom:link')[0].getAttribute('type')
|
mimetype: link.getAttribute('type')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return mediaData
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue