app/assets/javascripts/activestorage.js in activestorage-7.0.1 vs app/assets/javascripts/activestorage.js in activestorage-7.0.2

- old
+ new

@@ -501,20 +501,18 @@ } else { return [].slice.call(value); } } class BlobRecord { - constructor(file, checksum, url, directUploadToken, attachmentName) { + constructor(file, checksum, url) { this.file = file; this.attributes = { filename: file.name, content_type: file.type || "application/octet-stream", byte_size: file.size, checksum: checksum }; - this.directUploadToken = directUploadToken; - this.attachmentName = attachmentName; this.xhr = new XMLHttpRequest; this.xhr.open("POST", url, true); this.xhr.responseType = "json"; this.xhr.setRequestHeader("Content-Type", "application/json"); this.xhr.setRequestHeader("Accept", "application/json"); @@ -538,13 +536,11 @@ } } create(callback) { this.callback = callback; this.xhr.send(JSON.stringify({ - blob: this.attributes, - direct_upload_token: this.directUploadToken, - attachment_name: this.attachmentName + blob: this.attributes })); } requestDidLoad(event) { if (this.status >= 200 && this.status < 300) { const {response: response} = this; @@ -598,25 +594,23 @@ this.callback(`Error storing "${this.file.name}". Status: ${this.xhr.status}`); } } let id = 0; class DirectUpload { - constructor(file, url, serviceName, attachmentName, delegate) { + constructor(file, url, delegate) { this.id = ++id; this.file = file; this.url = url; - this.serviceName = serviceName; - this.attachmentName = attachmentName; this.delegate = delegate; } create(callback) { FileChecksum.create(this.file, ((error, checksum) => { if (error) { callback(error); return; } - const blob = new BlobRecord(this.file, checksum, this.url, this.serviceName, this.attachmentName); + const blob = new BlobRecord(this.file, checksum, this.url); notify(this.delegate, "directUploadWillCreateBlobWithXHR", blob.xhr); blob.create((error => { if (error) { callback(error); } else { @@ -641,11 +635,11 @@ } class DirectUploadController { constructor(input, file) { this.input = input; this.file = file; - this.directUpload = new DirectUpload(this.file, this.url, this.directUploadToken, this.attachmentName, this); + this.directUpload = new DirectUpload(this.file, this.url, this); this.dispatch("initialize"); } start(callback) { const hiddenInput = document.createElement("input"); hiddenInput.type = "hidden"; @@ -671,15 +665,9 @@ }); } } get url() { return this.input.getAttribute("data-direct-upload-url"); - } - get directUploadToken() { - return this.input.getAttribute("data-direct-upload-token"); - } - get attachmentName() { - return this.input.getAttribute("data-direct-upload-attachment-name"); } dispatch(name, detail = {}) { detail.file = this.file; detail.id = this.directUpload.id; return dispatchEvent(this.input, `direct-upload:${name}`, {