aboutsummaryrefslogtreecommitdiffstats
path: root/app/javascript/activestorage/blob_upload.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/javascript/activestorage/blob_upload.js')
-rw-r--r--app/javascript/activestorage/blob_upload.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/app/javascript/activestorage/blob_upload.js b/app/javascript/activestorage/blob_upload.js
index c72820b433..99bf0c9e30 100644
--- a/app/javascript/activestorage/blob_upload.js
+++ b/app/javascript/activestorage/blob_upload.js
@@ -3,10 +3,13 @@ export class BlobUpload {
this.blob = blob
this.file = blob.file
+ const { url, headers } = blob.directUploadData
+
this.xhr = new XMLHttpRequest
- this.xhr.open("PUT", blob.uploadURL, true)
- this.xhr.setRequestHeader("Content-Type", blob.attributes.content_type)
- this.xhr.setRequestHeader("Content-MD5", blob.attributes.checksum)
+ this.xhr.open("PUT", url, true)
+ for (const key in headers) {
+ this.xhr.setRequestHeader(key, headers[key])
+ }
this.xhr.addEventListener("load", event => this.requestDidLoad(event))
this.xhr.addEventListener("error", event => this.requestDidError(event))
}