@qrvey/object-storage 1.0.3 → 1.0.4-539
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 +1 -1
- package/dist/cjs/index.js +38 -414
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.d.mts +19 -45
- package/dist/esm/index.mjs +39 -415
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/index.d.ts +19 -45
- package/package.json +5 -9
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @qrvey/object-storage
|
|
2
2
|
|
|
3
3
|

|
|
4
|
-

|
|
5
5
|
|
|
6
6
|
The `@qrvey/object-storage` package provides a unified interface for ...
|
|
7
7
|
|
package/dist/cjs/index.js
CHANGED
|
@@ -8,7 +8,6 @@ var s3RequestPresigner = require('@aws-sdk/s3-request-presigner');
|
|
|
8
8
|
var libStorage = require('@aws-sdk/lib-storage');
|
|
9
9
|
var http = require('http');
|
|
10
10
|
var https = require('https');
|
|
11
|
-
var basicFtp = require('basic-ftp');
|
|
12
11
|
|
|
13
12
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
13
|
|
|
@@ -38,13 +37,6 @@ var __spreadValues = (a, b) => {
|
|
|
38
37
|
return a;
|
|
39
38
|
};
|
|
40
39
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
41
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
42
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
43
|
-
}) : x)(function(x) {
|
|
44
|
-
if (typeof require !== "undefined")
|
|
45
|
-
return require.apply(this, arguments);
|
|
46
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
47
|
-
});
|
|
48
40
|
var __objRest = (source, exclude) => {
|
|
49
41
|
var target = {};
|
|
50
42
|
for (var prop in source)
|
|
@@ -146,13 +138,12 @@ var BlobStorageService = class {
|
|
|
146
138
|
* Retrieves the properties of a blob from the container by its name.
|
|
147
139
|
*
|
|
148
140
|
* @param {string} blobName - The name of the blob.
|
|
149
|
-
* @param {ObjectStorageOptions} options - The options for the object storage service.
|
|
150
141
|
* @return {Promise<GetObjectResponse>} A promise that resolves to the blob properties.
|
|
151
142
|
*/
|
|
152
|
-
constructor(containerName
|
|
143
|
+
constructor(containerName) {
|
|
153
144
|
this.containerName = containerName;
|
|
154
145
|
this.blobServiceClient = storageBlob.BlobServiceClient.fromConnectionString(
|
|
155
|
-
|
|
146
|
+
process.env.AZURE_STORAGE_CONNECTION_STRING
|
|
156
147
|
);
|
|
157
148
|
}
|
|
158
149
|
/**
|
|
@@ -572,10 +563,11 @@ var BlobStorageService = class {
|
|
|
572
563
|
* Completes a multipart upload by committing the blocks to create the blob.
|
|
573
564
|
*
|
|
574
565
|
* @param {string} blobName - The name of the blob for which the multipart upload is being completed.
|
|
566
|
+
* @param {string} uploadId - The ID of the multipart upload to be completed.
|
|
575
567
|
* @return {Promise<void>} A Promise that resolves when the multipart upload is successfully completed.
|
|
576
568
|
* @throws {Error} If no block IDs are found in the metadata.
|
|
577
569
|
*/
|
|
578
|
-
async completeMultipartUpload(blobName) {
|
|
570
|
+
async completeMultipartUpload(blobName, uploadId) {
|
|
579
571
|
var _a;
|
|
580
572
|
const containerClient = this.blobServiceClient.getContainerClient(
|
|
581
573
|
this.containerName
|
|
@@ -1449,341 +1441,11 @@ var S3StorageService = class {
|
|
|
1449
1441
|
return presignedUrl;
|
|
1450
1442
|
}
|
|
1451
1443
|
};
|
|
1452
|
-
var SftpClient = __require("ssh2-sftp-client");
|
|
1453
|
-
var SftpStorageService = class {
|
|
1454
|
-
constructor(bucketName, options) {
|
|
1455
|
-
this.bucketName = bucketName;
|
|
1456
|
-
this.options = options || {};
|
|
1457
|
-
this.client = new SftpClient();
|
|
1458
|
-
}
|
|
1459
|
-
async initializeClient() {
|
|
1460
|
-
const host = this.options.host || process.env.SFTP_HOST;
|
|
1461
|
-
const port = parseInt(
|
|
1462
|
-
String(this.options.port || process.env.SFTP_PORT)
|
|
1463
|
-
);
|
|
1464
|
-
const user = this.options.user || process.env.SFTP_USER;
|
|
1465
|
-
const password = this.options.password || process.env.SFTP_PASSWORD;
|
|
1466
|
-
const privateKey = this.options.privateKey || process.env.SFTP_PRIVATE_KEY;
|
|
1467
|
-
if (!password && !privateKey) {
|
|
1468
|
-
throw new Error(
|
|
1469
|
-
"Either password or private key must be provided for SFTP connection"
|
|
1470
|
-
);
|
|
1471
|
-
}
|
|
1472
|
-
await this.client.connect({
|
|
1473
|
-
host,
|
|
1474
|
-
port,
|
|
1475
|
-
username: user,
|
|
1476
|
-
password,
|
|
1477
|
-
privateKey,
|
|
1478
|
-
readyTimeout: 4e3,
|
|
1479
|
-
retries: 1,
|
|
1480
|
-
retry_factor: 2,
|
|
1481
|
-
retry_minTimeout: 2e3
|
|
1482
|
-
});
|
|
1483
|
-
}
|
|
1484
|
-
async withClient(fn) {
|
|
1485
|
-
try {
|
|
1486
|
-
await this.initializeClient();
|
|
1487
|
-
return await fn();
|
|
1488
|
-
} finally {
|
|
1489
|
-
await this.client.end().catch(() => {
|
|
1490
|
-
});
|
|
1491
|
-
}
|
|
1492
|
-
}
|
|
1493
|
-
async list(options) {
|
|
1494
|
-
return this.withClient(async () => {
|
|
1495
|
-
const prefix = options.prefix || "";
|
|
1496
|
-
const path = this.bucketName + (prefix ? "/" + prefix : "");
|
|
1497
|
-
const list = await this.client.list(path);
|
|
1498
|
-
const items = list.map((item) => ({
|
|
1499
|
-
key: item.name,
|
|
1500
|
-
lastModified: item.modifyTime ? new Date(item.modifyTime) : /* @__PURE__ */ new Date(),
|
|
1501
|
-
size: item.size,
|
|
1502
|
-
eTag: ""
|
|
1503
|
-
}));
|
|
1504
|
-
return {
|
|
1505
|
-
items,
|
|
1506
|
-
pagination: null,
|
|
1507
|
-
count: items.length
|
|
1508
|
-
};
|
|
1509
|
-
});
|
|
1510
|
-
}
|
|
1511
|
-
async ensureDirectoriesExist(remotePath) {
|
|
1512
|
-
var _a, _b;
|
|
1513
|
-
const parts = remotePath.split("/");
|
|
1514
|
-
parts.pop();
|
|
1515
|
-
let current = "";
|
|
1516
|
-
for (const part of parts) {
|
|
1517
|
-
if (!part)
|
|
1518
|
-
continue;
|
|
1519
|
-
current += `/${part}`;
|
|
1520
|
-
try {
|
|
1521
|
-
await this.client.stat(current);
|
|
1522
|
-
} catch (err) {
|
|
1523
|
-
const isNoEntry = err.code === "ENOENT" || ((_a = err.message) == null ? void 0 : _a.includes("No such file")) || ((_b = err.message) == null ? void 0 : _b.includes("does not exist"));
|
|
1524
|
-
if (isNoEntry) {
|
|
1525
|
-
try {
|
|
1526
|
-
await this.client.mkdir(current);
|
|
1527
|
-
} catch (mkdirErr) {
|
|
1528
|
-
throw new Error(
|
|
1529
|
-
`Failed to create directory ${current}: ${mkdirErr.message}`
|
|
1530
|
-
);
|
|
1531
|
-
}
|
|
1532
|
-
} else {
|
|
1533
|
-
throw new Error(
|
|
1534
|
-
`Failed to check directory ${current}: ${err.message}`
|
|
1535
|
-
);
|
|
1536
|
-
}
|
|
1537
|
-
}
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
async upload(key, body) {
|
|
1541
|
-
return this.withClient(async () => {
|
|
1542
|
-
let remotePath = `${this.bucketName}/${key}`;
|
|
1543
|
-
remotePath = remotePath + "";
|
|
1544
|
-
await this.ensureDirectoriesExist(remotePath);
|
|
1545
|
-
if (body instanceof stream.Readable) {
|
|
1546
|
-
await this.client.put(body, remotePath);
|
|
1547
|
-
} else if (body instanceof Buffer) {
|
|
1548
|
-
await this.client.put(Buffer.from(body), remotePath);
|
|
1549
|
-
} else {
|
|
1550
|
-
await this.client.put(Buffer.from(String(body)), remotePath);
|
|
1551
|
-
}
|
|
1552
|
-
return { key };
|
|
1553
|
-
});
|
|
1554
|
-
}
|
|
1555
|
-
async delete(key) {
|
|
1556
|
-
return this.withClient(async () => {
|
|
1557
|
-
await this.client.delete(`${this.bucketName}/${key}`);
|
|
1558
|
-
return true;
|
|
1559
|
-
});
|
|
1560
|
-
}
|
|
1561
|
-
async getObject(key) {
|
|
1562
|
-
await this.initializeClient();
|
|
1563
|
-
const remotePath = `${this.bucketName}/${key}`;
|
|
1564
|
-
const stats = await this.client.stat(remotePath);
|
|
1565
|
-
const data = await this.client.get(remotePath);
|
|
1566
|
-
let stream3;
|
|
1567
|
-
if (Buffer.isBuffer(data) || typeof data === "string") {
|
|
1568
|
-
stream3 = stream.Readable.from(data);
|
|
1569
|
-
} else if (data instanceof stream.Readable) {
|
|
1570
|
-
stream3 = data;
|
|
1571
|
-
} else {
|
|
1572
|
-
throw new Error("Unsupported stream type returned by SFTP client");
|
|
1573
|
-
}
|
|
1574
|
-
const cleanup = async () => {
|
|
1575
|
-
try {
|
|
1576
|
-
await this.client.end();
|
|
1577
|
-
} catch (e) {
|
|
1578
|
-
}
|
|
1579
|
-
};
|
|
1580
|
-
stream3.on("end", cleanup);
|
|
1581
|
-
stream3.on("error", cleanup);
|
|
1582
|
-
return {
|
|
1583
|
-
body: stream3,
|
|
1584
|
-
contentLength: stats.size,
|
|
1585
|
-
lastModified: stats.modifyTime ? new Date(stats.modifyTime) : /* @__PURE__ */ new Date(),
|
|
1586
|
-
metadata: {}
|
|
1587
|
-
};
|
|
1588
|
-
}
|
|
1589
|
-
listAll(options) {
|
|
1590
|
-
throw new Error("Method not implemented.");
|
|
1591
|
-
}
|
|
1592
|
-
getHeadObject(key) {
|
|
1593
|
-
throw new Error("Method not implemented.");
|
|
1594
|
-
}
|
|
1595
|
-
getDownloadUrl(key, expiresInMinutes) {
|
|
1596
|
-
throw new Error("Method not implemented.");
|
|
1597
|
-
}
|
|
1598
|
-
getUploadUrl(key, expiresInMinutes) {
|
|
1599
|
-
throw new Error("Method not implemented.");
|
|
1600
|
-
}
|
|
1601
|
-
createUploadWriteStream(key) {
|
|
1602
|
-
throw new Error("Method not implemented.");
|
|
1603
|
-
}
|
|
1604
|
-
getHeadBucket() {
|
|
1605
|
-
throw new Error("Method not implemented.");
|
|
1606
|
-
}
|
|
1607
|
-
generateUploadIdMultipart(key) {
|
|
1608
|
-
throw new Error("Method not implemented.");
|
|
1609
|
-
}
|
|
1610
|
-
listMultipartUploadsForBucket() {
|
|
1611
|
-
throw new Error("Method not implemented.");
|
|
1612
|
-
}
|
|
1613
|
-
listMultipartUploadsForKey(key, uploadId) {
|
|
1614
|
-
throw new Error("Method not implemented.");
|
|
1615
|
-
}
|
|
1616
|
-
uploadMultipart(key, file, partNumber, uploadId) {
|
|
1617
|
-
throw new Error("Method not implemented.");
|
|
1618
|
-
}
|
|
1619
|
-
completeMultipartUpload(key, uploadId) {
|
|
1620
|
-
throw new Error("Method not implemented.");
|
|
1621
|
-
}
|
|
1622
|
-
abortMultipartUpload(key, uploadId) {
|
|
1623
|
-
throw new Error("Method not implemented.");
|
|
1624
|
-
}
|
|
1625
|
-
getMultipartUploadPresignedUrl(key, uploadId, partNumber, expiresInMinutes) {
|
|
1626
|
-
throw new Error("Method not implemented.");
|
|
1627
|
-
}
|
|
1628
|
-
};
|
|
1629
|
-
var FtpStorageService = class {
|
|
1630
|
-
constructor(bucketName, options) {
|
|
1631
|
-
this.bucketName = bucketName;
|
|
1632
|
-
this.options = options || {};
|
|
1633
|
-
this.client = new basicFtp.Client();
|
|
1634
|
-
}
|
|
1635
|
-
listAll(options) {
|
|
1636
|
-
throw new Error("Method not implemented.");
|
|
1637
|
-
}
|
|
1638
|
-
async initializeClient() {
|
|
1639
|
-
var _a, _b, _c, _d, _e;
|
|
1640
|
-
const host = ((_a = this == null ? void 0 : this.options) == null ? void 0 : _a.host) || process.env.FTP_HOST;
|
|
1641
|
-
const port = parseInt(
|
|
1642
|
-
String(((_b = this == null ? void 0 : this.options) == null ? void 0 : _b.port) || process.env.FTP_PORT),
|
|
1643
|
-
10
|
|
1644
|
-
);
|
|
1645
|
-
const user = ((_c = this == null ? void 0 : this.options) == null ? void 0 : _c.user) || process.env.FTP_USER;
|
|
1646
|
-
const password = ((_d = this == null ? void 0 : this.options) == null ? void 0 : _d.password) || process.env.FTP_PASSWORD;
|
|
1647
|
-
await this.client.access({
|
|
1648
|
-
host,
|
|
1649
|
-
port,
|
|
1650
|
-
user,
|
|
1651
|
-
password,
|
|
1652
|
-
secure: ((_e = this == null ? void 0 : this.options) == null ? void 0 : _e.secure) || false
|
|
1653
|
-
});
|
|
1654
|
-
}
|
|
1655
|
-
async withClient(fn) {
|
|
1656
|
-
try {
|
|
1657
|
-
await this.initializeClient();
|
|
1658
|
-
return await fn();
|
|
1659
|
-
} finally {
|
|
1660
|
-
this.client.close();
|
|
1661
|
-
}
|
|
1662
|
-
}
|
|
1663
|
-
async list(options) {
|
|
1664
|
-
return this.withClient(async () => {
|
|
1665
|
-
const prefix = options.prefix || "";
|
|
1666
|
-
const path = `${this.bucketName}/${prefix}`;
|
|
1667
|
-
try {
|
|
1668
|
-
const list = await this.client.list(path);
|
|
1669
|
-
const items = list.map(
|
|
1670
|
-
(item) => ({
|
|
1671
|
-
key: prefix + item.name,
|
|
1672
|
-
lastModified: item.modifiedAt || /* @__PURE__ */ new Date(),
|
|
1673
|
-
size: item.size,
|
|
1674
|
-
eTag: ""
|
|
1675
|
-
})
|
|
1676
|
-
);
|
|
1677
|
-
return {
|
|
1678
|
-
items,
|
|
1679
|
-
pagination: null,
|
|
1680
|
-
count: items.length
|
|
1681
|
-
};
|
|
1682
|
-
} catch (e) {
|
|
1683
|
-
return { items: [], pagination: null, count: 0 };
|
|
1684
|
-
}
|
|
1685
|
-
});
|
|
1686
|
-
}
|
|
1687
|
-
async getObject(key) {
|
|
1688
|
-
await this.initializeClient();
|
|
1689
|
-
const passThrough = new stream.PassThrough();
|
|
1690
|
-
const path = `${this.bucketName}/${key}`;
|
|
1691
|
-
const stats = await this.client.size(path);
|
|
1692
|
-
this.client.downloadTo(passThrough, path).then(() => passThrough.end()).catch((err) => passThrough.emit("error", err));
|
|
1693
|
-
const cleanup = () => {
|
|
1694
|
-
this.client.close();
|
|
1695
|
-
};
|
|
1696
|
-
passThrough.on("end", cleanup);
|
|
1697
|
-
passThrough.on("error", cleanup);
|
|
1698
|
-
return {
|
|
1699
|
-
body: passThrough,
|
|
1700
|
-
contentLength: stats,
|
|
1701
|
-
lastModified: /* @__PURE__ */ new Date(),
|
|
1702
|
-
metadata: {}
|
|
1703
|
-
};
|
|
1704
|
-
}
|
|
1705
|
-
async upload(key, body) {
|
|
1706
|
-
return this.withClient(async () => {
|
|
1707
|
-
await this.client.cd("/");
|
|
1708
|
-
try {
|
|
1709
|
-
await this.client.cd(this.bucketName);
|
|
1710
|
-
} catch (e) {
|
|
1711
|
-
await this.client.send(`MKD ${this.bucketName}`);
|
|
1712
|
-
await this.client.cd(this.bucketName);
|
|
1713
|
-
}
|
|
1714
|
-
const parts = key.split("/");
|
|
1715
|
-
parts.pop();
|
|
1716
|
-
for (const part of parts) {
|
|
1717
|
-
if (!part)
|
|
1718
|
-
continue;
|
|
1719
|
-
try {
|
|
1720
|
-
await this.client.cd(part);
|
|
1721
|
-
} catch (e) {
|
|
1722
|
-
await this.client.send(`MKD ${part}`);
|
|
1723
|
-
await this.client.cd(part);
|
|
1724
|
-
}
|
|
1725
|
-
}
|
|
1726
|
-
await this.client.cd("/");
|
|
1727
|
-
const fullPath = `${this.bucketName}/${key}`;
|
|
1728
|
-
const stream3 = body instanceof stream.Readable ? body : stream.Readable.from([body]);
|
|
1729
|
-
await this.client.uploadFrom(stream3, fullPath);
|
|
1730
|
-
return { key };
|
|
1731
|
-
});
|
|
1732
|
-
}
|
|
1733
|
-
async delete(key) {
|
|
1734
|
-
return this.withClient(async () => {
|
|
1735
|
-
await this.client.remove(`${this.bucketName}/${key}`);
|
|
1736
|
-
return true;
|
|
1737
|
-
});
|
|
1738
|
-
}
|
|
1739
|
-
async close() {
|
|
1740
|
-
this.client.close();
|
|
1741
|
-
}
|
|
1742
|
-
// Unsupported Operations
|
|
1743
|
-
async getDownloadUrl(_key, _expiresInMinutes) {
|
|
1744
|
-
throw new Error("FTP does not support pre-signed URLs");
|
|
1745
|
-
}
|
|
1746
|
-
async getUploadUrl(_key, _expiresInMinutes) {
|
|
1747
|
-
throw new Error("FTP does not support pre-signed URLs");
|
|
1748
|
-
}
|
|
1749
|
-
async getHeadObject(_key) {
|
|
1750
|
-
throw new Error("Operation not supported");
|
|
1751
|
-
}
|
|
1752
|
-
createUploadWriteStream(_key) {
|
|
1753
|
-
throw new Error("Operation not supported");
|
|
1754
|
-
}
|
|
1755
|
-
async getHeadBucket() {
|
|
1756
|
-
throw new Error("Operation not supported");
|
|
1757
|
-
}
|
|
1758
|
-
async generateUploadIdMultipart(_key) {
|
|
1759
|
-
throw new Error("Multipart upload is not supported");
|
|
1760
|
-
}
|
|
1761
|
-
async listMultipartUploadsForBucket() {
|
|
1762
|
-
throw new Error("Multipart upload is not supported");
|
|
1763
|
-
}
|
|
1764
|
-
async listMultipartUploadsForKey(_key, _uploadId) {
|
|
1765
|
-
throw new Error("Multipart upload is not supported");
|
|
1766
|
-
}
|
|
1767
|
-
async uploadMultipart(_key, _file, _partNumber, _uploadId) {
|
|
1768
|
-
throw new Error("Multipart upload is not supported");
|
|
1769
|
-
}
|
|
1770
|
-
async completeMultipartUpload(_key, _uploadId) {
|
|
1771
|
-
throw new Error("Multipart upload is not supported");
|
|
1772
|
-
}
|
|
1773
|
-
async abortMultipartUpload(_key, _uploadId) {
|
|
1774
|
-
throw new Error("Method not implemented.");
|
|
1775
|
-
}
|
|
1776
|
-
async getMultipartUploadPresignedUrl(_key, _uploadId, _partNumber, _expiresInMinutes) {
|
|
1777
|
-
throw new Error("Multipart upload is not supported");
|
|
1778
|
-
}
|
|
1779
|
-
};
|
|
1780
1444
|
|
|
1781
1445
|
// src/shared/utils/constants.ts
|
|
1782
1446
|
var OBJECT_STORAGE_SERVICE_TYPES = {
|
|
1783
1447
|
AWS_S3: "aws_s3",
|
|
1784
|
-
AZURE_BLOB_STORAGE: "azure_blob_storage"
|
|
1785
|
-
FTP: "ftp",
|
|
1786
|
-
SFTP: "sftp"
|
|
1448
|
+
AZURE_BLOB_STORAGE: "azure_blob_storage"
|
|
1787
1449
|
};
|
|
1788
1450
|
|
|
1789
1451
|
// src/services/objectStorageFactory.service.ts
|
|
@@ -1795,11 +1457,7 @@ var ObjectStorageFactory = class {
|
|
|
1795
1457
|
case OBJECT_STORAGE_SERVICE_TYPES.AWS_S3:
|
|
1796
1458
|
return new S3StorageService(bucketName, options);
|
|
1797
1459
|
case OBJECT_STORAGE_SERVICE_TYPES.AZURE_BLOB_STORAGE:
|
|
1798
|
-
return new BlobStorageService(bucketName
|
|
1799
|
-
case OBJECT_STORAGE_SERVICE_TYPES.FTP:
|
|
1800
|
-
return new FtpStorageService(bucketName, options);
|
|
1801
|
-
case OBJECT_STORAGE_SERVICE_TYPES.SFTP:
|
|
1802
|
-
return new SftpStorageService(bucketName, options);
|
|
1460
|
+
return new BlobStorageService(bucketName);
|
|
1803
1461
|
default:
|
|
1804
1462
|
throw new Error(
|
|
1805
1463
|
`Unsupported object storage provider: ${provider}`
|
|
@@ -1825,13 +1483,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1825
1483
|
*
|
|
1826
1484
|
* @param {ListRequestOptions} options - The options to apply to the list operation.
|
|
1827
1485
|
* @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
|
|
1828
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1829
1486
|
* @return {Promise<ListResponse>} A promise that resolves to the list of objects.
|
|
1830
1487
|
*/
|
|
1831
|
-
static async list(options, bucketName
|
|
1488
|
+
static async list(options, bucketName) {
|
|
1832
1489
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1833
|
-
bucketName
|
|
1834
|
-
objectStorageOptions
|
|
1490
|
+
bucketName
|
|
1835
1491
|
).then((instance) => instance.list(options));
|
|
1836
1492
|
}
|
|
1837
1493
|
/**
|
|
@@ -1839,13 +1495,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1839
1495
|
*
|
|
1840
1496
|
* @param {ListRequestOptions} options - The options to apply to the list operation.
|
|
1841
1497
|
* @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
|
|
1842
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1843
1498
|
* @return {Promise<ListResponse>} A promise that resolves to the list of all objects.
|
|
1844
1499
|
*/
|
|
1845
|
-
static async listAll(options, bucketName
|
|
1500
|
+
static async listAll(options, bucketName) {
|
|
1846
1501
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1847
|
-
bucketName
|
|
1848
|
-
objectStorageOptions
|
|
1502
|
+
bucketName
|
|
1849
1503
|
).then((instance) => instance.listAll(options));
|
|
1850
1504
|
}
|
|
1851
1505
|
/**
|
|
@@ -1853,27 +1507,21 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1853
1507
|
*
|
|
1854
1508
|
* @param {string} key - The key of the object to retrieve.
|
|
1855
1509
|
* @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
|
|
1856
|
-
* @param {IGetObjectOptions} [options] - The options to apply to the get operation.
|
|
1857
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1858
1510
|
* @return {Promise<GetObjectResponse>} A promise that resolves to the retrieved object.
|
|
1859
1511
|
*/
|
|
1860
|
-
static async getObject(key, bucketName, options
|
|
1512
|
+
static async getObject(key, bucketName, options) {
|
|
1861
1513
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1862
|
-
bucketName
|
|
1863
|
-
objectStorageOptions
|
|
1514
|
+
bucketName
|
|
1864
1515
|
).then((instance) => instance.getObject(key, options));
|
|
1865
1516
|
}
|
|
1866
1517
|
/**
|
|
1867
1518
|
* Retrieves an object info (without file content) from the object storage service.
|
|
1868
1519
|
* @param key - The key of the object to retrieve.
|
|
1869
|
-
* @param bucketName - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
|
|
1870
|
-
* @param objectStorageOptions - The options for the object storage service.
|
|
1871
1520
|
* @returns A promise that resolves to the info of the file.
|
|
1872
1521
|
*/
|
|
1873
|
-
static async getHeadObject(key, bucketName
|
|
1522
|
+
static async getHeadObject(key, bucketName) {
|
|
1874
1523
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1875
|
-
bucketName
|
|
1876
|
-
objectStorageOptions
|
|
1524
|
+
bucketName
|
|
1877
1525
|
).then((instance) => instance.getHeadObject(key));
|
|
1878
1526
|
}
|
|
1879
1527
|
/**
|
|
@@ -1882,13 +1530,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1882
1530
|
* @param {string} key - The key of the object for which to generate the signed URL.
|
|
1883
1531
|
* @param {number} expiresInMinutes - The number of minutes until the signed URL expires.
|
|
1884
1532
|
* @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
|
|
1885
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1886
1533
|
* @return {Promise<string>} A promise that resolves to the generated signed URL.
|
|
1887
1534
|
*/
|
|
1888
|
-
static async getDownloadUrl(key, expiresInMinutes, bucketName
|
|
1535
|
+
static async getDownloadUrl(key, expiresInMinutes, bucketName) {
|
|
1889
1536
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1890
|
-
bucketName
|
|
1891
|
-
objectStorageOptions
|
|
1537
|
+
bucketName
|
|
1892
1538
|
).then((instance) => instance.getDownloadUrl(key, expiresInMinutes));
|
|
1893
1539
|
}
|
|
1894
1540
|
/**
|
|
@@ -1897,13 +1543,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1897
1543
|
* @param {string} key - The key of the object for which to generate the upload URL.
|
|
1898
1544
|
* @param {number} expiresInMinutes - The number of minutes until the upload URL expires.
|
|
1899
1545
|
* @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
|
|
1900
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1901
1546
|
* @return {Promise<string>} A promise that resolves to the generated upload URL.
|
|
1902
1547
|
*/
|
|
1903
|
-
static async getUploadUrl(key, expiresInMinutes, bucketName
|
|
1548
|
+
static async getUploadUrl(key, expiresInMinutes, bucketName) {
|
|
1904
1549
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1905
|
-
bucketName
|
|
1906
|
-
objectStorageOptions
|
|
1550
|
+
bucketName
|
|
1907
1551
|
).then((instance) => instance.getUploadUrl(key, expiresInMinutes));
|
|
1908
1552
|
}
|
|
1909
1553
|
/**
|
|
@@ -1913,13 +1557,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1913
1557
|
* @param {FileContent} body - The content of the file to upload.
|
|
1914
1558
|
* @param {Object} [metadata] - Optional metadata to associate with the object.
|
|
1915
1559
|
* @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
|
|
1916
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1917
1560
|
* @return {Promise<UploadResponse>} A promise that resolves to the response of the upload operation.
|
|
1918
1561
|
*/
|
|
1919
|
-
static async upload(key, body, metadata, bucketName
|
|
1562
|
+
static async upload(key, body, metadata, bucketName) {
|
|
1920
1563
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1921
|
-
bucketName
|
|
1922
|
-
objectStorageOptions
|
|
1564
|
+
bucketName
|
|
1923
1565
|
).then((instance) => instance.upload(key, body, metadata));
|
|
1924
1566
|
}
|
|
1925
1567
|
/**
|
|
@@ -1927,13 +1569,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1927
1569
|
*
|
|
1928
1570
|
* @param {string} key - The key of the object to create the upload write stream for.
|
|
1929
1571
|
* @param {string} [bucketName] - The name of the bucket where the object will be stored. If not provided, the default bucket name will be used.
|
|
1930
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1931
1572
|
* @return {Promise<CreateUploadWriteStreamResponse>} A promise that resolves to the response of the upload operation.
|
|
1932
1573
|
*/
|
|
1933
|
-
static async createUploadWriteStream(key, bucketName
|
|
1574
|
+
static async createUploadWriteStream(key, bucketName) {
|
|
1934
1575
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1935
|
-
bucketName
|
|
1936
|
-
objectStorageOptions
|
|
1576
|
+
bucketName
|
|
1937
1577
|
).then((instance) => instance.createUploadWriteStream(key));
|
|
1938
1578
|
}
|
|
1939
1579
|
/**
|
|
@@ -1941,13 +1581,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1941
1581
|
*
|
|
1942
1582
|
* @param {string | string[]} key - The key or array of keys of the objects to delete.
|
|
1943
1583
|
* @param {string} [bucketName] - The name of the bucket where the objects are stored. If not provided, the default bucket name will be used.
|
|
1944
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1945
1584
|
* @return {Promise<{ key: string; deleted: boolean; error?: string }[] | boolean>} A promise that resolves to an array of objects containing the key, deleted status, and an optional error message for each object deleted, or a boolean value indicating the success of the deletion.
|
|
1946
1585
|
*/
|
|
1947
|
-
static async delete(key, bucketName
|
|
1586
|
+
static async delete(key, bucketName) {
|
|
1948
1587
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1949
|
-
bucketName
|
|
1950
|
-
objectStorageOptions
|
|
1588
|
+
bucketName
|
|
1951
1589
|
).then(async (instance) => {
|
|
1952
1590
|
if (Array.isArray(key)) {
|
|
1953
1591
|
const deleteBlobPromises = key.map(async (blobName) => {
|
|
@@ -1973,13 +1611,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1973
1611
|
* Retrieves the head bucket from the object storage service.
|
|
1974
1612
|
*
|
|
1975
1613
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
1976
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1977
1614
|
* @return {Promise<HeadBucketResponse>} A promise that resolves to the head bucket response.
|
|
1978
1615
|
*/
|
|
1979
|
-
static async getHeadBucket(bucketName
|
|
1616
|
+
static async getHeadBucket(bucketName) {
|
|
1980
1617
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1981
|
-
bucketName
|
|
1982
|
-
objectStorageOptions
|
|
1618
|
+
bucketName
|
|
1983
1619
|
).then((instance) => instance.getHeadBucket());
|
|
1984
1620
|
}
|
|
1985
1621
|
/**
|
|
@@ -1987,13 +1623,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1987
1623
|
*
|
|
1988
1624
|
* @param {string} key - The key of the object to upload.
|
|
1989
1625
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
1990
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1991
1626
|
* @return {Promise<string>} A promise that resolves to the generated upload ID.
|
|
1992
1627
|
*/
|
|
1993
|
-
static async generateUploadIdMultipart(key, bucketName
|
|
1628
|
+
static async generateUploadIdMultipart(key, bucketName) {
|
|
1994
1629
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1995
|
-
bucketName
|
|
1996
|
-
objectStorageOptions
|
|
1630
|
+
bucketName
|
|
1997
1631
|
).then((instance) => instance.generateUploadIdMultipart(key));
|
|
1998
1632
|
}
|
|
1999
1633
|
/**
|
|
@@ -2002,13 +1636,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
2002
1636
|
* @param {string} key - The key of the object to retrieve uploads for.
|
|
2003
1637
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
2004
1638
|
* @param {string} [uploadId] - The upload ID to filter the results by.
|
|
2005
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
2006
1639
|
* @return {Promise<ListPartsMultipartUploadResponse>} A promise that resolves to the list of multipart uploads for the specified key.
|
|
2007
1640
|
*/
|
|
2008
|
-
static async listMultipartUploadsForKey(key, bucketName, uploadId
|
|
1641
|
+
static async listMultipartUploadsForKey(key, bucketName, uploadId) {
|
|
2009
1642
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2010
|
-
bucketName
|
|
2011
|
-
objectStorageOptions
|
|
1643
|
+
bucketName
|
|
2012
1644
|
).then(
|
|
2013
1645
|
(instance) => instance.listMultipartUploadsForKey(key, uploadId)
|
|
2014
1646
|
);
|
|
@@ -2017,13 +1649,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
2017
1649
|
* Retrieves a list of all multipart uploads for a specified bucket in the object storage service.
|
|
2018
1650
|
*
|
|
2019
1651
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
2020
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
2021
1652
|
* @return {Promise<ListMultipartUploadsResponse>} A promise that resolves to the list of multipart uploads for the specified bucket.
|
|
2022
1653
|
*/
|
|
2023
|
-
static async listMultipartUploadsForBucket(bucketName
|
|
1654
|
+
static async listMultipartUploadsForBucket(bucketName) {
|
|
2024
1655
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2025
|
-
bucketName
|
|
2026
|
-
objectStorageOptions
|
|
1656
|
+
bucketName
|
|
2027
1657
|
).then((instance) => instance.listMultipartUploadsForBucket());
|
|
2028
1658
|
}
|
|
2029
1659
|
/**
|
|
@@ -2034,13 +1664,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
2034
1664
|
* @param {number} partNumber - The number of the part being uploaded.
|
|
2035
1665
|
* @param {string} [uploadId] - The ID of the multipart upload.
|
|
2036
1666
|
* @param {string} [bucketName] - The name of the bucket to upload the file to. If not provided, the default bucket name will be used.
|
|
2037
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
2038
1667
|
* @return {Promise<string>} A Promise that resolves to the base64 encoded block ID of the uploaded part.
|
|
2039
1668
|
*/
|
|
2040
|
-
static async uploadMultipart(key, file, partNumber, uploadId, bucketName
|
|
1669
|
+
static async uploadMultipart(key, file, partNumber, uploadId, bucketName) {
|
|
2041
1670
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2042
|
-
bucketName
|
|
2043
|
-
objectStorageOptions
|
|
1671
|
+
bucketName
|
|
2044
1672
|
).then(
|
|
2045
1673
|
(instance) => instance.uploadMultipart(key, file, partNumber, uploadId)
|
|
2046
1674
|
);
|
|
@@ -2051,13 +1679,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
2051
1679
|
* @param {string} key - The key of the object to complete the multipart upload for.
|
|
2052
1680
|
* @param {string} uploadId - The ID of the multipart upload to complete.
|
|
2053
1681
|
* @param {string} [bucketName] - The name of the bucket to complete the multipart upload in. If not provided, the default bucket name will be used.
|
|
2054
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
2055
1682
|
* @return {Promise<void>} A Promise that resolves when the multipart upload is completed.
|
|
2056
1683
|
*/
|
|
2057
|
-
static async completeMultipartUpload(key, uploadId, bucketName
|
|
1684
|
+
static async completeMultipartUpload(key, uploadId, bucketName) {
|
|
2058
1685
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2059
|
-
bucketName
|
|
2060
|
-
objectStorageOptions
|
|
1686
|
+
bucketName
|
|
2061
1687
|
).then((instance) => instance.completeMultipartUpload(key, uploadId));
|
|
2062
1688
|
}
|
|
2063
1689
|
/**
|
|
@@ -2066,13 +1692,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
2066
1692
|
* @param {string} key - The key of the object to abort the multipart upload for.
|
|
2067
1693
|
* @param {string} uploadId - The ID of the multipart upload to abort.
|
|
2068
1694
|
* @param {string} [bucketName] - The name of the bucket to abort the multipart upload in. If not provided, the default bucket name will be used.
|
|
2069
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
2070
1695
|
* @return {Promise<void>} A Promise that resolves when the multipart upload is aborted.
|
|
2071
1696
|
*/
|
|
2072
|
-
static async abortMultipartUpload(key, uploadId, bucketName
|
|
1697
|
+
static async abortMultipartUpload(key, uploadId, bucketName) {
|
|
2073
1698
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2074
|
-
bucketName
|
|
2075
|
-
objectStorageOptions
|
|
1699
|
+
bucketName
|
|
2076
1700
|
).then((instance) => instance.abortMultipartUpload(key, uploadId));
|
|
2077
1701
|
}
|
|
2078
1702
|
/**
|