@raketa-builder/file-input 0.1.0 → 0.3.0

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.
package/dist/index.js CHANGED
@@ -861,7 +861,14 @@ var IMAGE = [
861
861
  "mage/heic",
862
862
  "mage/heic-sequence"
863
863
  ];
864
- var ARCHIVE = ["application/zip", "application/x-rar-compressed"];
864
+ var ARCHIVE = [
865
+ "application/zip",
866
+ "application/gzip",
867
+ "application/x-gtar",
868
+ "application/x-tar",
869
+ "application/x-rar-compressed",
870
+ "application/x-7z-compressed"
871
+ ];
865
872
  var MIME_TYPES = IMAGE.concat(VIDEO).concat(DOCUMENT).concat(AUDIO).concat(ARCHIVE);
866
873
  var MAPPING = {
867
874
  video: VIDEO,
@@ -1762,7 +1769,6 @@ var DELETE_DOCUMENT_MUTATION = `
1762
1769
  `;
1763
1770
  function uploadFile(file, document2, progressCallback) {
1764
1771
  return __async(this, null, function* () {
1765
- const blob = new Blob([new Uint8Array(file.size + 20)]);
1766
1772
  const xhr = new XMLHttpRequest();
1767
1773
  return new Promise((resolve) => {
1768
1774
  xhr.upload.addEventListener("progress", (event) => {
@@ -1795,7 +1801,11 @@ function uploadFile(file, document2, progressCallback) {
1795
1801
  xhr.withCredentials = false;
1796
1802
  xhr.open("PUT", document2.uploadUrl, true);
1797
1803
  xhr.setRequestHeader("content-type", file.type);
1798
- xhr.send(blob);
1804
+ var reader = new FileReader();
1805
+ reader.onload = function(event) {
1806
+ xhr.send(event.target.result);
1807
+ };
1808
+ reader.readAsArrayBuffer(file);
1799
1809
  });
1800
1810
  });
1801
1811
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raketa-builder/file-input",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "license": "MIT",
@@ -91,7 +91,6 @@ const DELETE_DOCUMENT_MUTATION = `
91
91
  `;
92
92
 
93
93
  async function uploadFile(file, document, progressCallback) {
94
- const blob = new Blob([new Uint8Array(file.size + 20)]);
95
94
  const xhr = new XMLHttpRequest();
96
95
 
97
96
  return new Promise((resolve) => {
@@ -129,7 +128,14 @@ async function uploadFile(file, document, progressCallback) {
129
128
  xhr.withCredentials = false;
130
129
  xhr.open("PUT", document.uploadUrl, true);
131
130
  xhr.setRequestHeader("content-type", file.type);
132
- xhr.send(blob);
131
+
132
+ // Read the file as ArrayBuffer and send it!
133
+ var reader = new FileReader();
134
+ reader.onload = function (event) {
135
+ xhr.send(event.target.result);
136
+ };
137
+
138
+ reader.readAsArrayBuffer(file);
133
139
  });
134
140
  }
135
141
 
package/src/styles.css CHANGED
@@ -14,7 +14,7 @@
14
14
  right: 0;
15
15
  bottom: 0;
16
16
  left: 0;
17
- z-index: 1200;
17
+ z-index: 1300;
18
18
  display: flex;
19
19
  justify-content: center;
20
20
  align-items: center;