提交 1a5bf01f 编写于 作者: J Javan Makhmali

Active Storage: Fix direct uploads in IE 11

Fixes #31531
Closes #31540
上级 08e03cfd
......@@ -22,14 +22,28 @@ export class BlobRecord {
this.xhr.addEventListener("error", event => this.requestDidError(event))
}
get status() {
return this.xhr.status
}
get response() {
const { responseType, response } = this.xhr
if (responseType == "json") {
return response
} else {
// Shim for IE 11: https://connect.microsoft.com/IE/feedback/details/794808
return JSON.parse(response)
}
}
create(callback) {
this.callback = callback
this.xhr.send(JSON.stringify({ blob: this.attributes }))
}
requestDidLoad(event) {
const { status, response } = this.xhr
if (status >= 200 && status < 300) {
if (this.status >= 200 && this.status < 300) {
const { response } = this
const { direct_upload } = response
delete response.direct_upload
this.attributes = response
......@@ -41,7 +55,7 @@ export class BlobRecord {
}
requestDidError(event) {
this.callback(`Error creating Blob for "${this.file.name}". Status: ${this.xhr.status}`)
this.callback(`Error creating Blob for "${this.file.name}". Status: ${this.status}`)
}
toJSON() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册