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

Active Storage: Fix direct uploads in IE 11

Fixes #31531
Closes #31540
上级 08e03cfd
...@@ -22,14 +22,28 @@ export class BlobRecord { ...@@ -22,14 +22,28 @@ export class BlobRecord {
this.xhr.addEventListener("error", event => this.requestDidError(event)) 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) { create(callback) {
this.callback = callback this.callback = callback
this.xhr.send(JSON.stringify({ blob: this.attributes })) this.xhr.send(JSON.stringify({ blob: this.attributes }))
} }
requestDidLoad(event) { requestDidLoad(event) {
const { status, response } = this.xhr if (this.status >= 200 && this.status < 300) {
if (status >= 200 && status < 300) { const { response } = this
const { direct_upload } = response const { direct_upload } = response
delete response.direct_upload delete response.direct_upload
this.attributes = response this.attributes = response
...@@ -41,7 +55,7 @@ export class BlobRecord { ...@@ -41,7 +55,7 @@ export class BlobRecord {
} }
requestDidError(event) { 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() { toJSON() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册