@rails/activestorage 7.0.0-rc2 → 7.0.2-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -508,7 +508,7 @@ function toArray(value) {
|
|
|
508
508
|
}
|
|
509
509
|
|
|
510
510
|
class BlobRecord {
|
|
511
|
-
constructor(file, checksum, url
|
|
511
|
+
constructor(file, checksum, url) {
|
|
512
512
|
this.file = file;
|
|
513
513
|
this.attributes = {
|
|
514
514
|
filename: file.name,
|
|
@@ -516,8 +516,6 @@ class BlobRecord {
|
|
|
516
516
|
byte_size: file.size,
|
|
517
517
|
checksum: checksum
|
|
518
518
|
};
|
|
519
|
-
this.directUploadToken = directUploadToken;
|
|
520
|
-
this.attachmentName = attachmentName;
|
|
521
519
|
this.xhr = new XMLHttpRequest;
|
|
522
520
|
this.xhr.open("POST", url, true);
|
|
523
521
|
this.xhr.responseType = "json";
|
|
@@ -545,9 +543,7 @@ class BlobRecord {
|
|
|
545
543
|
create(callback) {
|
|
546
544
|
this.callback = callback;
|
|
547
545
|
this.xhr.send(JSON.stringify({
|
|
548
|
-
blob: this.attributes
|
|
549
|
-
direct_upload_token: this.directUploadToken,
|
|
550
|
-
attachment_name: this.attachmentName
|
|
546
|
+
blob: this.attributes
|
|
551
547
|
}));
|
|
552
548
|
}
|
|
553
549
|
requestDidLoad(event) {
|
|
@@ -608,12 +604,10 @@ class BlobUpload {
|
|
|
608
604
|
let id = 0;
|
|
609
605
|
|
|
610
606
|
class DirectUpload {
|
|
611
|
-
constructor(file, url,
|
|
607
|
+
constructor(file, url, delegate) {
|
|
612
608
|
this.id = ++id;
|
|
613
609
|
this.file = file;
|
|
614
610
|
this.url = url;
|
|
615
|
-
this.serviceName = serviceName;
|
|
616
|
-
this.attachmentName = attachmentName;
|
|
617
611
|
this.delegate = delegate;
|
|
618
612
|
}
|
|
619
613
|
create(callback) {
|
|
@@ -622,7 +616,7 @@ class DirectUpload {
|
|
|
622
616
|
callback(error);
|
|
623
617
|
return;
|
|
624
618
|
}
|
|
625
|
-
const blob = new BlobRecord(this.file, checksum, this.url
|
|
619
|
+
const blob = new BlobRecord(this.file, checksum, this.url);
|
|
626
620
|
notify(this.delegate, "directUploadWillCreateBlobWithXHR", blob.xhr);
|
|
627
621
|
blob.create((error => {
|
|
628
622
|
if (error) {
|
|
@@ -653,7 +647,7 @@ class DirectUploadController {
|
|
|
653
647
|
constructor(input, file) {
|
|
654
648
|
this.input = input;
|
|
655
649
|
this.file = file;
|
|
656
|
-
this.directUpload = new DirectUpload(this.file, this.url, this
|
|
650
|
+
this.directUpload = new DirectUpload(this.file, this.url, this);
|
|
657
651
|
this.dispatch("initialize");
|
|
658
652
|
}
|
|
659
653
|
start(callback) {
|
|
@@ -684,12 +678,6 @@ class DirectUploadController {
|
|
|
684
678
|
get url() {
|
|
685
679
|
return this.input.getAttribute("data-direct-upload-url");
|
|
686
680
|
}
|
|
687
|
-
get directUploadToken() {
|
|
688
|
-
return this.input.getAttribute("data-direct-upload-token");
|
|
689
|
-
}
|
|
690
|
-
get attachmentName() {
|
|
691
|
-
return this.input.getAttribute("data-direct-upload-attachment-name");
|
|
692
|
-
}
|
|
693
681
|
dispatch(name, detail = {}) {
|
|
694
682
|
detail.file = this.file;
|
|
695
683
|
detail.id = this.directUpload.id;
|
|
@@ -503,7 +503,7 @@
|
|
|
503
503
|
}
|
|
504
504
|
}
|
|
505
505
|
class BlobRecord {
|
|
506
|
-
constructor(file, checksum, url
|
|
506
|
+
constructor(file, checksum, url) {
|
|
507
507
|
this.file = file;
|
|
508
508
|
this.attributes = {
|
|
509
509
|
filename: file.name,
|
|
@@ -511,8 +511,6 @@
|
|
|
511
511
|
byte_size: file.size,
|
|
512
512
|
checksum: checksum
|
|
513
513
|
};
|
|
514
|
-
this.directUploadToken = directUploadToken;
|
|
515
|
-
this.attachmentName = attachmentName;
|
|
516
514
|
this.xhr = new XMLHttpRequest;
|
|
517
515
|
this.xhr.open("POST", url, true);
|
|
518
516
|
this.xhr.responseType = "json";
|
|
@@ -540,9 +538,7 @@
|
|
|
540
538
|
create(callback) {
|
|
541
539
|
this.callback = callback;
|
|
542
540
|
this.xhr.send(JSON.stringify({
|
|
543
|
-
blob: this.attributes
|
|
544
|
-
direct_upload_token: this.directUploadToken,
|
|
545
|
-
attachment_name: this.attachmentName
|
|
541
|
+
blob: this.attributes
|
|
546
542
|
}));
|
|
547
543
|
}
|
|
548
544
|
requestDidLoad(event) {
|
|
@@ -600,12 +596,10 @@
|
|
|
600
596
|
}
|
|
601
597
|
let id = 0;
|
|
602
598
|
class DirectUpload {
|
|
603
|
-
constructor(file, url,
|
|
599
|
+
constructor(file, url, delegate) {
|
|
604
600
|
this.id = ++id;
|
|
605
601
|
this.file = file;
|
|
606
602
|
this.url = url;
|
|
607
|
-
this.serviceName = serviceName;
|
|
608
|
-
this.attachmentName = attachmentName;
|
|
609
603
|
this.delegate = delegate;
|
|
610
604
|
}
|
|
611
605
|
create(callback) {
|
|
@@ -614,7 +608,7 @@
|
|
|
614
608
|
callback(error);
|
|
615
609
|
return;
|
|
616
610
|
}
|
|
617
|
-
const blob = new BlobRecord(this.file, checksum, this.url
|
|
611
|
+
const blob = new BlobRecord(this.file, checksum, this.url);
|
|
618
612
|
notify(this.delegate, "directUploadWillCreateBlobWithXHR", blob.xhr);
|
|
619
613
|
blob.create((error => {
|
|
620
614
|
if (error) {
|
|
@@ -643,7 +637,7 @@
|
|
|
643
637
|
constructor(input, file) {
|
|
644
638
|
this.input = input;
|
|
645
639
|
this.file = file;
|
|
646
|
-
this.directUpload = new DirectUpload(this.file, this.url, this
|
|
640
|
+
this.directUpload = new DirectUpload(this.file, this.url, this);
|
|
647
641
|
this.dispatch("initialize");
|
|
648
642
|
}
|
|
649
643
|
start(callback) {
|
|
@@ -674,12 +668,6 @@
|
|
|
674
668
|
get url() {
|
|
675
669
|
return this.input.getAttribute("data-direct-upload-url");
|
|
676
670
|
}
|
|
677
|
-
get directUploadToken() {
|
|
678
|
-
return this.input.getAttribute("data-direct-upload-token");
|
|
679
|
-
}
|
|
680
|
-
get attachmentName() {
|
|
681
|
-
return this.input.getAttribute("data-direct-upload-attachment-name");
|
|
682
|
-
}
|
|
683
671
|
dispatch(name, detail = {}) {
|
|
684
672
|
detail.file = this.file;
|
|
685
673
|
detail.id = this.directUpload.id;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rails/activestorage",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.2-1",
|
|
4
4
|
"description": "Attach cloud and local files in Rails applications",
|
|
5
5
|
"module": "app/assets/javascripts/activestorage.esm.js",
|
|
6
6
|
"main": "app/assets/javascripts/activestorage.js",
|
package/src/blob_record.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import { getMetaValue } from "./helpers"
|
|
2
2
|
|
|
3
3
|
export class BlobRecord {
|
|
4
|
-
constructor(file, checksum, url
|
|
4
|
+
constructor(file, checksum, url) {
|
|
5
5
|
this.file = file
|
|
6
6
|
|
|
7
7
|
this.attributes = {
|
|
8
8
|
filename: file.name,
|
|
9
9
|
content_type: file.type || "application/octet-stream",
|
|
10
10
|
byte_size: file.size,
|
|
11
|
-
checksum: checksum
|
|
11
|
+
checksum: checksum
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
this.directUploadToken = directUploadToken
|
|
15
|
-
this.attachmentName = attachmentName
|
|
16
|
-
|
|
17
14
|
this.xhr = new XMLHttpRequest
|
|
18
15
|
this.xhr.open("POST", url, true)
|
|
19
16
|
this.xhr.responseType = "json"
|
|
@@ -46,11 +43,7 @@ export class BlobRecord {
|
|
|
46
43
|
|
|
47
44
|
create(callback) {
|
|
48
45
|
this.callback = callback
|
|
49
|
-
this.xhr.send(JSON.stringify({
|
|
50
|
-
blob: this.attributes,
|
|
51
|
-
direct_upload_token: this.directUploadToken,
|
|
52
|
-
attachment_name: this.attachmentName
|
|
53
|
-
}))
|
|
46
|
+
this.xhr.send(JSON.stringify({ blob: this.attributes }))
|
|
54
47
|
}
|
|
55
48
|
|
|
56
49
|
requestDidLoad(event) {
|
package/src/direct_upload.js
CHANGED
|
@@ -5,12 +5,10 @@ import { BlobUpload } from "./blob_upload"
|
|
|
5
5
|
let id = 0
|
|
6
6
|
|
|
7
7
|
export class DirectUpload {
|
|
8
|
-
constructor(file, url,
|
|
8
|
+
constructor(file, url, delegate) {
|
|
9
9
|
this.id = ++id
|
|
10
10
|
this.file = file
|
|
11
11
|
this.url = url
|
|
12
|
-
this.serviceName = serviceName
|
|
13
|
-
this.attachmentName = attachmentName
|
|
14
12
|
this.delegate = delegate
|
|
15
13
|
}
|
|
16
14
|
|
|
@@ -21,7 +19,7 @@ export class DirectUpload {
|
|
|
21
19
|
return
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
const blob = new BlobRecord(this.file, checksum, this.url
|
|
22
|
+
const blob = new BlobRecord(this.file, checksum, this.url)
|
|
25
23
|
notify(this.delegate, "directUploadWillCreateBlobWithXHR", blob.xhr)
|
|
26
24
|
|
|
27
25
|
blob.create(error => {
|
|
@@ -5,7 +5,7 @@ export class DirectUploadController {
|
|
|
5
5
|
constructor(input, file) {
|
|
6
6
|
this.input = input
|
|
7
7
|
this.file = file
|
|
8
|
-
this.directUpload = new DirectUpload(this.file, this.url, this
|
|
8
|
+
this.directUpload = new DirectUpload(this.file, this.url, this)
|
|
9
9
|
this.dispatch("initialize")
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -41,14 +41,6 @@ export class DirectUploadController {
|
|
|
41
41
|
return this.input.getAttribute("data-direct-upload-url")
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
get directUploadToken() {
|
|
45
|
-
return this.input.getAttribute("data-direct-upload-token")
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
get attachmentName() {
|
|
49
|
-
return this.input.getAttribute("data-direct-upload-attachment-name")
|
|
50
|
-
}
|
|
51
|
-
|
|
52
44
|
dispatch(name, detail = {}) {
|
|
53
45
|
detail.file = this.file
|
|
54
46
|
detail.id = this.directUpload.id
|