hydrousdb 3.5.4 → 3.5.6
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/README.md +17 -5
- package/dist/index.cjs +69 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.mjs +69 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1405,20 +1405,20 @@ declare const AUTH: {
|
|
|
1405
1405
|
declare const STORAGE: {
|
|
1406
1406
|
readonly base: "/storage";
|
|
1407
1407
|
readonly upload: "/storage/upload";
|
|
1408
|
-
readonly uploadRaw: "/storage/upload
|
|
1409
|
-
readonly uploadUrl: "/storage/upload
|
|
1410
|
-
readonly confirm: "/storage/
|
|
1411
|
-
readonly batchUploadUrls: "/storage/upload
|
|
1412
|
-
readonly batchConfirm: "/storage/
|
|
1408
|
+
readonly uploadRaw: "/storage/upload-raw";
|
|
1409
|
+
readonly uploadUrl: "/storage/upload-url";
|
|
1410
|
+
readonly confirm: "/storage/confirm";
|
|
1411
|
+
readonly batchUploadUrls: "/storage/batch-upload-urls";
|
|
1412
|
+
readonly batchConfirm: "/storage/batch-confirm";
|
|
1413
1413
|
readonly download: (encodedPath: string) => string;
|
|
1414
|
-
readonly batchDownload: "/storage/download
|
|
1414
|
+
readonly batchDownload: "/storage/batch-download";
|
|
1415
1415
|
readonly list: "/storage/list";
|
|
1416
1416
|
readonly metadata: (encodedPath: string) => string;
|
|
1417
1417
|
readonly signedUrl: "/storage/signed-url";
|
|
1418
1418
|
readonly visibility: "/storage/visibility";
|
|
1419
1419
|
readonly folder: "/storage/folder";
|
|
1420
1420
|
readonly file: "/storage/file";
|
|
1421
|
-
readonly folderDelete: "/storage/folder
|
|
1421
|
+
readonly folderDelete: "/storage/folder";
|
|
1422
1422
|
readonly move: "/storage/move";
|
|
1423
1423
|
readonly copy: "/storage/copy";
|
|
1424
1424
|
readonly stats: "/storage/stats";
|
package/dist/index.d.ts
CHANGED
|
@@ -1405,20 +1405,20 @@ declare const AUTH: {
|
|
|
1405
1405
|
declare const STORAGE: {
|
|
1406
1406
|
readonly base: "/storage";
|
|
1407
1407
|
readonly upload: "/storage/upload";
|
|
1408
|
-
readonly uploadRaw: "/storage/upload
|
|
1409
|
-
readonly uploadUrl: "/storage/upload
|
|
1410
|
-
readonly confirm: "/storage/
|
|
1411
|
-
readonly batchUploadUrls: "/storage/upload
|
|
1412
|
-
readonly batchConfirm: "/storage/
|
|
1408
|
+
readonly uploadRaw: "/storage/upload-raw";
|
|
1409
|
+
readonly uploadUrl: "/storage/upload-url";
|
|
1410
|
+
readonly confirm: "/storage/confirm";
|
|
1411
|
+
readonly batchUploadUrls: "/storage/batch-upload-urls";
|
|
1412
|
+
readonly batchConfirm: "/storage/batch-confirm";
|
|
1413
1413
|
readonly download: (encodedPath: string) => string;
|
|
1414
|
-
readonly batchDownload: "/storage/download
|
|
1414
|
+
readonly batchDownload: "/storage/batch-download";
|
|
1415
1415
|
readonly list: "/storage/list";
|
|
1416
1416
|
readonly metadata: (encodedPath: string) => string;
|
|
1417
1417
|
readonly signedUrl: "/storage/signed-url";
|
|
1418
1418
|
readonly visibility: "/storage/visibility";
|
|
1419
1419
|
readonly folder: "/storage/folder";
|
|
1420
1420
|
readonly file: "/storage/file";
|
|
1421
|
-
readonly folderDelete: "/storage/folder
|
|
1421
|
+
readonly folderDelete: "/storage/folder";
|
|
1422
1422
|
readonly move: "/storage/move";
|
|
1423
1423
|
readonly copy: "/storage/copy";
|
|
1424
1424
|
readonly stats: "/storage/stats";
|
package/dist/index.mjs
CHANGED
|
@@ -150,18 +150,76 @@ var HttpClient = class {
|
|
|
150
150
|
*/
|
|
151
151
|
async putToSignedUrl(signedUrl, data, mimeType, onProgress) {
|
|
152
152
|
const body = data;
|
|
153
|
-
if (typeof XMLHttpRequest !== "undefined"
|
|
153
|
+
if (typeof XMLHttpRequest !== "undefined") {
|
|
154
154
|
await new Promise((resolve, reject) => {
|
|
155
155
|
const xhr = new XMLHttpRequest();
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
156
|
+
if (typeof onProgress === "function") {
|
|
157
|
+
xhr.upload.onprogress = (e) => {
|
|
158
|
+
if (e.lengthComputable) onProgress(Math.round(e.loaded / e.total * 100));
|
|
159
|
+
};
|
|
160
|
+
}
|
|
159
161
|
xhr.onload = () => xhr.status >= 200 && xhr.status < 300 ? resolve() : reject(new Error(`GCS upload failed: ${xhr.status}`));
|
|
160
162
|
xhr.onerror = () => reject(new Error("GCS upload network error"));
|
|
161
163
|
xhr.open("PUT", signedUrl);
|
|
162
164
|
xhr.setRequestHeader("Content-Type", mimeType);
|
|
163
165
|
xhr.send(body);
|
|
164
166
|
});
|
|
167
|
+
} else if (typeof process !== "undefined" && process.versions && process.versions.node) {
|
|
168
|
+
const https = await import('https');
|
|
169
|
+
const { URL } = await import('url');
|
|
170
|
+
let buffer;
|
|
171
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer(body)) {
|
|
172
|
+
buffer = body;
|
|
173
|
+
} else if (body instanceof ArrayBuffer) {
|
|
174
|
+
buffer = Buffer.from(body);
|
|
175
|
+
} else if (body instanceof Uint8Array) {
|
|
176
|
+
buffer = Buffer.from(body.buffer, body.byteOffset, body.byteLength);
|
|
177
|
+
} else if (typeof Blob !== "undefined" && body instanceof Blob) {
|
|
178
|
+
const arrayBuffer = await body.arrayBuffer();
|
|
179
|
+
buffer = Buffer.from(arrayBuffer);
|
|
180
|
+
} else {
|
|
181
|
+
buffer = Buffer.from(String(body));
|
|
182
|
+
}
|
|
183
|
+
const urlObj = new URL(signedUrl);
|
|
184
|
+
const options = {
|
|
185
|
+
method: "PUT",
|
|
186
|
+
hostname: urlObj.hostname,
|
|
187
|
+
path: urlObj.pathname + urlObj.search,
|
|
188
|
+
headers: {
|
|
189
|
+
"Content-Type": mimeType,
|
|
190
|
+
"Content-Length": String(buffer.length)
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
await new Promise((resolve, reject) => {
|
|
194
|
+
const req = https.request(options, (res) => {
|
|
195
|
+
if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
|
|
196
|
+
resolve();
|
|
197
|
+
} else {
|
|
198
|
+
reject(new Error(`GCS upload failed: ${res.statusCode}`));
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
req.on("error", (err) => {
|
|
202
|
+
reject(err);
|
|
203
|
+
});
|
|
204
|
+
const totalBytes = buffer.length;
|
|
205
|
+
let writtenBytes = 0;
|
|
206
|
+
const chunkSize = 64 * 1024;
|
|
207
|
+
const writeChunk = () => {
|
|
208
|
+
if (writtenBytes < totalBytes) {
|
|
209
|
+
const nextChunkSize = Math.min(chunkSize, totalBytes - writtenBytes);
|
|
210
|
+
const chunk = buffer.subarray(writtenBytes, writtenBytes + nextChunkSize);
|
|
211
|
+
req.write(chunk);
|
|
212
|
+
writtenBytes += nextChunkSize;
|
|
213
|
+
if (typeof onProgress === "function") {
|
|
214
|
+
onProgress(Math.round(writtenBytes / totalBytes * 100));
|
|
215
|
+
}
|
|
216
|
+
setImmediate(writeChunk);
|
|
217
|
+
} else {
|
|
218
|
+
req.end();
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
writeChunk();
|
|
222
|
+
});
|
|
165
223
|
} else {
|
|
166
224
|
const res = await fetch(signedUrl, {
|
|
167
225
|
method: "PUT",
|
|
@@ -227,20 +285,20 @@ var AUTH = {
|
|
|
227
285
|
var STORAGE = {
|
|
228
286
|
base: "/storage",
|
|
229
287
|
upload: "/storage/upload",
|
|
230
|
-
uploadRaw: "/storage/upload
|
|
231
|
-
uploadUrl: "/storage/upload
|
|
232
|
-
confirm: "/storage/
|
|
233
|
-
batchUploadUrls: "/storage/upload
|
|
234
|
-
batchConfirm: "/storage/
|
|
288
|
+
uploadRaw: "/storage/upload-raw",
|
|
289
|
+
uploadUrl: "/storage/upload-url",
|
|
290
|
+
confirm: "/storage/confirm",
|
|
291
|
+
batchUploadUrls: "/storage/batch-upload-urls",
|
|
292
|
+
batchConfirm: "/storage/batch-confirm",
|
|
235
293
|
download: (encodedPath) => `/storage/download/${encodedPath}`,
|
|
236
|
-
batchDownload: "/storage/download
|
|
294
|
+
batchDownload: "/storage/batch-download",
|
|
237
295
|
list: "/storage/list",
|
|
238
296
|
metadata: (encodedPath) => `/storage/metadata/${encodedPath}`,
|
|
239
297
|
signedUrl: "/storage/signed-url",
|
|
240
298
|
visibility: "/storage/visibility",
|
|
241
299
|
folder: "/storage/folder",
|
|
242
300
|
file: "/storage/file",
|
|
243
|
-
folderDelete: "/storage/folder
|
|
301
|
+
folderDelete: "/storage/folder",
|
|
244
302
|
move: "/storage/move",
|
|
245
303
|
copy: "/storage/copy",
|
|
246
304
|
stats: "/storage/stats",
|