Update actiontext JavaScript
This commit is contained in:
parent
c93a989635
commit
d0ed4c8ecc
@ -508,7 +508,7 @@ function toArray(value) {
|
||||
}
|
||||
|
||||
class BlobRecord {
|
||||
constructor(file, checksum, url) {
|
||||
constructor(file, checksum, url, customHeaders = {}) {
|
||||
this.file = file;
|
||||
this.attributes = {
|
||||
filename: file.name,
|
||||
@ -522,6 +522,9 @@ class BlobRecord {
|
||||
this.xhr.setRequestHeader("Content-Type", "application/json");
|
||||
this.xhr.setRequestHeader("Accept", "application/json");
|
||||
this.xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
|
||||
Object.keys(customHeaders).forEach((headerKey => {
|
||||
this.xhr.setRequestHeader(headerKey, customHeaders[headerKey]);
|
||||
}));
|
||||
const csrfToken = getMetaValue("csrf-token");
|
||||
if (csrfToken != undefined) {
|
||||
this.xhr.setRequestHeader("X-CSRF-Token", csrfToken);
|
||||
@ -604,11 +607,12 @@ class BlobUpload {
|
||||
let id = 0;
|
||||
|
||||
class DirectUpload {
|
||||
constructor(file, url, delegate) {
|
||||
constructor(file, url, delegate, customHeaders = {}) {
|
||||
this.id = ++id;
|
||||
this.file = file;
|
||||
this.url = url;
|
||||
this.delegate = delegate;
|
||||
this.customHeaders = customHeaders;
|
||||
}
|
||||
create(callback) {
|
||||
FileChecksum.create(this.file, ((error, checksum) => {
|
||||
@ -616,7 +620,7 @@ class DirectUpload {
|
||||
callback(error);
|
||||
return;
|
||||
}
|
||||
const blob = new BlobRecord(this.file, checksum, this.url);
|
||||
const blob = new BlobRecord(this.file, checksum, this.url, this.customHeaders);
|
||||
notify(this.delegate, "directUploadWillCreateBlobWithXHR", blob.xhr);
|
||||
blob.create((error => {
|
||||
if (error) {
|
||||
|
Loading…
Reference in New Issue
Block a user