@gigadrive/sdk 0.8.0 → 0.8.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.
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1086,11 +1086,15 @@ var sizeOf = (data) => {
|
|
|
1086
1086
|
if (data instanceof ArrayBuffer) return data.byteLength;
|
|
1087
1087
|
throw new Error("Cannot determine upload size. Pass a File, Blob, Buffer, Uint8Array, or ArrayBuffer.");
|
|
1088
1088
|
};
|
|
1089
|
-
var toTusFile = (data) => {
|
|
1090
|
-
if (
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1089
|
+
var toTusFile = async (data) => {
|
|
1090
|
+
if (!isNode()) {
|
|
1091
|
+
if (typeof Blob !== "undefined" && data instanceof Blob) return data;
|
|
1092
|
+
const bytes2 = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
1093
|
+
return new Blob([bytes2]);
|
|
1094
|
+
}
|
|
1095
|
+
const { Buffer: Buffer2 } = await import("buffer");
|
|
1096
|
+
const bytes = typeof Blob !== "undefined" && data instanceof Blob ? new Uint8Array(await data.arrayBuffer()) : data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
1097
|
+
return Buffer2.isBuffer(data) ? data : Buffer2.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
1094
1098
|
};
|
|
1095
1099
|
var buildChecksums = (input, sha256) => {
|
|
1096
1100
|
const checksums = { sha256 };
|
|
@@ -1111,7 +1115,7 @@ var resolveUploadSource = async (input, options = {}) => {
|
|
|
1111
1115
|
const size = input.contentLength ?? sizeOf(input.data);
|
|
1112
1116
|
const sha256 = input.checksumSha256 ?? (hash ? (await computeChecksums(await toBytes(input.data))).sha256 : "");
|
|
1113
1117
|
return {
|
|
1114
|
-
tusFile: toTusFile(input.data),
|
|
1118
|
+
tusFile: await toTusFile(input.data),
|
|
1115
1119
|
size,
|
|
1116
1120
|
contentType,
|
|
1117
1121
|
checksums: buildChecksums(input, sha256),
|