@qrvey/object-storage 1.0.3-beta → 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/dist/cjs/index.js +38 -383
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.d.mts +19 -45
- package/dist/esm/index.mjs +39 -384
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/index.d.ts +19 -45
- package/package.json +6 -10
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,310 +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 upload(key, body) {
|
|
1512
|
-
return this.withClient(async () => {
|
|
1513
|
-
const remotePath = `${this.bucketName}/${key}`;
|
|
1514
|
-
if (body instanceof stream.Readable) {
|
|
1515
|
-
await this.client.put(body, remotePath);
|
|
1516
|
-
} else if (body instanceof Buffer) {
|
|
1517
|
-
await this.client.put(Buffer.from(body), remotePath);
|
|
1518
|
-
} else {
|
|
1519
|
-
await this.client.put(Buffer.from(String(body)), remotePath);
|
|
1520
|
-
}
|
|
1521
|
-
return { key };
|
|
1522
|
-
});
|
|
1523
|
-
}
|
|
1524
|
-
async delete(key) {
|
|
1525
|
-
return this.withClient(async () => {
|
|
1526
|
-
await this.client.delete(`${this.bucketName}/${key}`);
|
|
1527
|
-
return true;
|
|
1528
|
-
});
|
|
1529
|
-
}
|
|
1530
|
-
async getObject(key) {
|
|
1531
|
-
await this.initializeClient();
|
|
1532
|
-
const remotePath = `${this.bucketName}/${key}`;
|
|
1533
|
-
const stats = await this.client.stat(remotePath);
|
|
1534
|
-
const data = await this.client.get(remotePath);
|
|
1535
|
-
let stream3;
|
|
1536
|
-
if (Buffer.isBuffer(data) || typeof data === "string") {
|
|
1537
|
-
stream3 = stream.Readable.from(data);
|
|
1538
|
-
} else if (data instanceof stream.Readable) {
|
|
1539
|
-
stream3 = data;
|
|
1540
|
-
} else {
|
|
1541
|
-
throw new Error("Unsupported stream type returned by SFTP client");
|
|
1542
|
-
}
|
|
1543
|
-
const cleanup = async () => {
|
|
1544
|
-
try {
|
|
1545
|
-
await this.client.end();
|
|
1546
|
-
} catch (e) {
|
|
1547
|
-
}
|
|
1548
|
-
};
|
|
1549
|
-
stream3.on("end", cleanup);
|
|
1550
|
-
stream3.on("error", cleanup);
|
|
1551
|
-
return {
|
|
1552
|
-
body: stream3,
|
|
1553
|
-
contentLength: stats.size,
|
|
1554
|
-
lastModified: stats.modifyTime ? new Date(stats.modifyTime) : /* @__PURE__ */ new Date(),
|
|
1555
|
-
metadata: {}
|
|
1556
|
-
};
|
|
1557
|
-
}
|
|
1558
|
-
listAll(options) {
|
|
1559
|
-
throw new Error("Method not implemented.");
|
|
1560
|
-
}
|
|
1561
|
-
getHeadObject(key) {
|
|
1562
|
-
throw new Error("Method not implemented.");
|
|
1563
|
-
}
|
|
1564
|
-
getDownloadUrl(key, expiresInMinutes) {
|
|
1565
|
-
throw new Error("Method not implemented.");
|
|
1566
|
-
}
|
|
1567
|
-
getUploadUrl(key, expiresInMinutes) {
|
|
1568
|
-
throw new Error("Method not implemented.");
|
|
1569
|
-
}
|
|
1570
|
-
createUploadWriteStream(key) {
|
|
1571
|
-
throw new Error("Method not implemented.");
|
|
1572
|
-
}
|
|
1573
|
-
getHeadBucket() {
|
|
1574
|
-
throw new Error("Method not implemented.");
|
|
1575
|
-
}
|
|
1576
|
-
generateUploadIdMultipart(key) {
|
|
1577
|
-
throw new Error("Method not implemented.");
|
|
1578
|
-
}
|
|
1579
|
-
listMultipartUploadsForBucket() {
|
|
1580
|
-
throw new Error("Method not implemented.");
|
|
1581
|
-
}
|
|
1582
|
-
listMultipartUploadsForKey(key, uploadId) {
|
|
1583
|
-
throw new Error("Method not implemented.");
|
|
1584
|
-
}
|
|
1585
|
-
uploadMultipart(key, file, partNumber, uploadId) {
|
|
1586
|
-
throw new Error("Method not implemented.");
|
|
1587
|
-
}
|
|
1588
|
-
completeMultipartUpload(key, uploadId) {
|
|
1589
|
-
throw new Error("Method not implemented.");
|
|
1590
|
-
}
|
|
1591
|
-
abortMultipartUpload(key, uploadId) {
|
|
1592
|
-
throw new Error("Method not implemented.");
|
|
1593
|
-
}
|
|
1594
|
-
getMultipartUploadPresignedUrl(key, uploadId, partNumber, expiresInMinutes) {
|
|
1595
|
-
throw new Error("Method not implemented.");
|
|
1596
|
-
}
|
|
1597
|
-
};
|
|
1598
|
-
var FtpStorageService = class {
|
|
1599
|
-
constructor(bucketName, options) {
|
|
1600
|
-
this.bucketName = bucketName;
|
|
1601
|
-
this.options = options || {};
|
|
1602
|
-
this.client = new basicFtp.Client();
|
|
1603
|
-
}
|
|
1604
|
-
listAll(options) {
|
|
1605
|
-
throw new Error("Method not implemented.");
|
|
1606
|
-
}
|
|
1607
|
-
async initializeClient() {
|
|
1608
|
-
var _a, _b, _c, _d, _e;
|
|
1609
|
-
const host = ((_a = this == null ? void 0 : this.options) == null ? void 0 : _a.host) || process.env.FTP_HOST;
|
|
1610
|
-
const port = parseInt(
|
|
1611
|
-
String(((_b = this == null ? void 0 : this.options) == null ? void 0 : _b.port) || process.env.FTP_PORT),
|
|
1612
|
-
10
|
|
1613
|
-
);
|
|
1614
|
-
const user = ((_c = this == null ? void 0 : this.options) == null ? void 0 : _c.user) || process.env.FTP_USER;
|
|
1615
|
-
const password = ((_d = this == null ? void 0 : this.options) == null ? void 0 : _d.password) || process.env.FTP_PASSWORD;
|
|
1616
|
-
await this.client.access({
|
|
1617
|
-
host,
|
|
1618
|
-
port,
|
|
1619
|
-
user,
|
|
1620
|
-
password,
|
|
1621
|
-
secure: ((_e = this == null ? void 0 : this.options) == null ? void 0 : _e.secure) || false
|
|
1622
|
-
});
|
|
1623
|
-
}
|
|
1624
|
-
async withClient(fn) {
|
|
1625
|
-
try {
|
|
1626
|
-
await this.initializeClient();
|
|
1627
|
-
return await fn();
|
|
1628
|
-
} finally {
|
|
1629
|
-
this.client.close();
|
|
1630
|
-
}
|
|
1631
|
-
}
|
|
1632
|
-
async list(options) {
|
|
1633
|
-
return this.withClient(async () => {
|
|
1634
|
-
const prefix = options.prefix || "";
|
|
1635
|
-
const path = `${this.bucketName}/${prefix}`;
|
|
1636
|
-
try {
|
|
1637
|
-
const list = await this.client.list(path);
|
|
1638
|
-
const items = list.map(
|
|
1639
|
-
(item) => ({
|
|
1640
|
-
key: prefix + item.name,
|
|
1641
|
-
lastModified: item.modifiedAt || /* @__PURE__ */ new Date(),
|
|
1642
|
-
size: item.size,
|
|
1643
|
-
eTag: ""
|
|
1644
|
-
})
|
|
1645
|
-
);
|
|
1646
|
-
return {
|
|
1647
|
-
items,
|
|
1648
|
-
pagination: null,
|
|
1649
|
-
count: items.length
|
|
1650
|
-
};
|
|
1651
|
-
} catch (e) {
|
|
1652
|
-
return { items: [], pagination: null, count: 0 };
|
|
1653
|
-
}
|
|
1654
|
-
});
|
|
1655
|
-
}
|
|
1656
|
-
async getObject(key) {
|
|
1657
|
-
await this.initializeClient();
|
|
1658
|
-
const passThrough = new stream.PassThrough();
|
|
1659
|
-
const path = `${this.bucketName}/${key}`;
|
|
1660
|
-
const stats = await this.client.size(path);
|
|
1661
|
-
this.client.downloadTo(passThrough, path).then(() => passThrough.end()).catch((err) => passThrough.emit("error", err));
|
|
1662
|
-
const cleanup = () => {
|
|
1663
|
-
this.client.close();
|
|
1664
|
-
};
|
|
1665
|
-
passThrough.on("end", cleanup);
|
|
1666
|
-
passThrough.on("error", cleanup);
|
|
1667
|
-
return {
|
|
1668
|
-
body: passThrough,
|
|
1669
|
-
contentLength: stats,
|
|
1670
|
-
lastModified: /* @__PURE__ */ new Date(),
|
|
1671
|
-
metadata: {}
|
|
1672
|
-
};
|
|
1673
|
-
}
|
|
1674
|
-
async upload(key, body) {
|
|
1675
|
-
return this.withClient(async () => {
|
|
1676
|
-
await this.client.cd("/");
|
|
1677
|
-
try {
|
|
1678
|
-
await this.client.cd(this.bucketName);
|
|
1679
|
-
} catch (e) {
|
|
1680
|
-
await this.client.send(`MKD ${this.bucketName}`);
|
|
1681
|
-
await this.client.cd(this.bucketName);
|
|
1682
|
-
}
|
|
1683
|
-
const parts = key.split("/");
|
|
1684
|
-
parts.pop();
|
|
1685
|
-
for (const part of parts) {
|
|
1686
|
-
if (!part)
|
|
1687
|
-
continue;
|
|
1688
|
-
try {
|
|
1689
|
-
await this.client.cd(part);
|
|
1690
|
-
} catch (e) {
|
|
1691
|
-
await this.client.send(`MKD ${part}`);
|
|
1692
|
-
await this.client.cd(part);
|
|
1693
|
-
}
|
|
1694
|
-
}
|
|
1695
|
-
await this.client.cd("/");
|
|
1696
|
-
const fullPath = `${this.bucketName}/${key}`;
|
|
1697
|
-
const stream3 = body instanceof stream.Readable ? body : stream.Readable.from([body]);
|
|
1698
|
-
await this.client.uploadFrom(stream3, fullPath);
|
|
1699
|
-
return { key };
|
|
1700
|
-
});
|
|
1701
|
-
}
|
|
1702
|
-
async delete(key) {
|
|
1703
|
-
return this.withClient(async () => {
|
|
1704
|
-
await this.client.remove(`${this.bucketName}/${key}`);
|
|
1705
|
-
return true;
|
|
1706
|
-
});
|
|
1707
|
-
}
|
|
1708
|
-
async close() {
|
|
1709
|
-
this.client.close();
|
|
1710
|
-
}
|
|
1711
|
-
// Unsupported Operations
|
|
1712
|
-
async getDownloadUrl(_key, _expiresInMinutes) {
|
|
1713
|
-
throw new Error("FTP does not support pre-signed URLs");
|
|
1714
|
-
}
|
|
1715
|
-
async getUploadUrl(_key, _expiresInMinutes) {
|
|
1716
|
-
throw new Error("FTP does not support pre-signed URLs");
|
|
1717
|
-
}
|
|
1718
|
-
async getHeadObject(_key) {
|
|
1719
|
-
throw new Error("Operation not supported");
|
|
1720
|
-
}
|
|
1721
|
-
createUploadWriteStream(_key) {
|
|
1722
|
-
throw new Error("Operation not supported");
|
|
1723
|
-
}
|
|
1724
|
-
async getHeadBucket() {
|
|
1725
|
-
throw new Error("Operation not supported");
|
|
1726
|
-
}
|
|
1727
|
-
async generateUploadIdMultipart(_key) {
|
|
1728
|
-
throw new Error("Multipart upload is not supported");
|
|
1729
|
-
}
|
|
1730
|
-
async listMultipartUploadsForBucket() {
|
|
1731
|
-
throw new Error("Multipart upload is not supported");
|
|
1732
|
-
}
|
|
1733
|
-
async listMultipartUploadsForKey(_key, _uploadId) {
|
|
1734
|
-
throw new Error("Multipart upload is not supported");
|
|
1735
|
-
}
|
|
1736
|
-
async uploadMultipart(_key, _file, _partNumber, _uploadId) {
|
|
1737
|
-
throw new Error("Multipart upload is not supported");
|
|
1738
|
-
}
|
|
1739
|
-
async completeMultipartUpload(_key, _uploadId) {
|
|
1740
|
-
throw new Error("Multipart upload is not supported");
|
|
1741
|
-
}
|
|
1742
|
-
async abortMultipartUpload(_key, _uploadId) {
|
|
1743
|
-
throw new Error("Method not implemented.");
|
|
1744
|
-
}
|
|
1745
|
-
async getMultipartUploadPresignedUrl(_key, _uploadId, _partNumber, _expiresInMinutes) {
|
|
1746
|
-
throw new Error("Multipart upload is not supported");
|
|
1747
|
-
}
|
|
1748
|
-
};
|
|
1749
1444
|
|
|
1750
1445
|
// src/shared/utils/constants.ts
|
|
1751
1446
|
var OBJECT_STORAGE_SERVICE_TYPES = {
|
|
1752
1447
|
AWS_S3: "aws_s3",
|
|
1753
|
-
AZURE_BLOB_STORAGE: "azure_blob_storage"
|
|
1754
|
-
FTP: "ftp",
|
|
1755
|
-
SFTP: "sftp"
|
|
1448
|
+
AZURE_BLOB_STORAGE: "azure_blob_storage"
|
|
1756
1449
|
};
|
|
1757
1450
|
|
|
1758
1451
|
// src/services/objectStorageFactory.service.ts
|
|
@@ -1764,11 +1457,7 @@ var ObjectStorageFactory = class {
|
|
|
1764
1457
|
case OBJECT_STORAGE_SERVICE_TYPES.AWS_S3:
|
|
1765
1458
|
return new S3StorageService(bucketName, options);
|
|
1766
1459
|
case OBJECT_STORAGE_SERVICE_TYPES.AZURE_BLOB_STORAGE:
|
|
1767
|
-
return new BlobStorageService(bucketName
|
|
1768
|
-
case OBJECT_STORAGE_SERVICE_TYPES.FTP:
|
|
1769
|
-
return new FtpStorageService(bucketName, options);
|
|
1770
|
-
case OBJECT_STORAGE_SERVICE_TYPES.SFTP:
|
|
1771
|
-
return new SftpStorageService(bucketName, options);
|
|
1460
|
+
return new BlobStorageService(bucketName);
|
|
1772
1461
|
default:
|
|
1773
1462
|
throw new Error(
|
|
1774
1463
|
`Unsupported object storage provider: ${provider}`
|
|
@@ -1794,13 +1483,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1794
1483
|
*
|
|
1795
1484
|
* @param {ListRequestOptions} options - The options to apply to the list operation.
|
|
1796
1485
|
* @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
|
|
1797
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1798
1486
|
* @return {Promise<ListResponse>} A promise that resolves to the list of objects.
|
|
1799
1487
|
*/
|
|
1800
|
-
static async list(options, bucketName
|
|
1488
|
+
static async list(options, bucketName) {
|
|
1801
1489
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1802
|
-
bucketName
|
|
1803
|
-
objectStorageOptions
|
|
1490
|
+
bucketName
|
|
1804
1491
|
).then((instance) => instance.list(options));
|
|
1805
1492
|
}
|
|
1806
1493
|
/**
|
|
@@ -1808,13 +1495,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1808
1495
|
*
|
|
1809
1496
|
* @param {ListRequestOptions} options - The options to apply to the list operation.
|
|
1810
1497
|
* @param {string} [bucketName] - The name of the bucket to list objects from. If not provided, the default bucket name will be used.
|
|
1811
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1812
1498
|
* @return {Promise<ListResponse>} A promise that resolves to the list of all objects.
|
|
1813
1499
|
*/
|
|
1814
|
-
static async listAll(options, bucketName
|
|
1500
|
+
static async listAll(options, bucketName) {
|
|
1815
1501
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1816
|
-
bucketName
|
|
1817
|
-
objectStorageOptions
|
|
1502
|
+
bucketName
|
|
1818
1503
|
).then((instance) => instance.listAll(options));
|
|
1819
1504
|
}
|
|
1820
1505
|
/**
|
|
@@ -1822,27 +1507,21 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1822
1507
|
*
|
|
1823
1508
|
* @param {string} key - The key of the object to retrieve.
|
|
1824
1509
|
* @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
|
|
1825
|
-
* @param {IGetObjectOptions} [options] - The options to apply to the get operation.
|
|
1826
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1827
1510
|
* @return {Promise<GetObjectResponse>} A promise that resolves to the retrieved object.
|
|
1828
1511
|
*/
|
|
1829
|
-
static async getObject(key, bucketName, options
|
|
1512
|
+
static async getObject(key, bucketName, options) {
|
|
1830
1513
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1831
|
-
bucketName
|
|
1832
|
-
objectStorageOptions
|
|
1514
|
+
bucketName
|
|
1833
1515
|
).then((instance) => instance.getObject(key, options));
|
|
1834
1516
|
}
|
|
1835
1517
|
/**
|
|
1836
1518
|
* Retrieves an object info (without file content) from the object storage service.
|
|
1837
1519
|
* @param key - The key of the object to retrieve.
|
|
1838
|
-
* @param bucketName - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
|
|
1839
|
-
* @param objectStorageOptions - The options for the object storage service.
|
|
1840
1520
|
* @returns A promise that resolves to the info of the file.
|
|
1841
1521
|
*/
|
|
1842
|
-
static async getHeadObject(key, bucketName
|
|
1522
|
+
static async getHeadObject(key, bucketName) {
|
|
1843
1523
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1844
|
-
bucketName
|
|
1845
|
-
objectStorageOptions
|
|
1524
|
+
bucketName
|
|
1846
1525
|
).then((instance) => instance.getHeadObject(key));
|
|
1847
1526
|
}
|
|
1848
1527
|
/**
|
|
@@ -1851,13 +1530,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1851
1530
|
* @param {string} key - The key of the object for which to generate the signed URL.
|
|
1852
1531
|
* @param {number} expiresInMinutes - The number of minutes until the signed URL expires.
|
|
1853
1532
|
* @param {string} [bucketName] - The name of the bucket where the object is stored. If not provided, the default bucket name will be used.
|
|
1854
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1855
1533
|
* @return {Promise<string>} A promise that resolves to the generated signed URL.
|
|
1856
1534
|
*/
|
|
1857
|
-
static async getDownloadUrl(key, expiresInMinutes, bucketName
|
|
1535
|
+
static async getDownloadUrl(key, expiresInMinutes, bucketName) {
|
|
1858
1536
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1859
|
-
bucketName
|
|
1860
|
-
objectStorageOptions
|
|
1537
|
+
bucketName
|
|
1861
1538
|
).then((instance) => instance.getDownloadUrl(key, expiresInMinutes));
|
|
1862
1539
|
}
|
|
1863
1540
|
/**
|
|
@@ -1866,13 +1543,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1866
1543
|
* @param {string} key - The key of the object for which to generate the upload URL.
|
|
1867
1544
|
* @param {number} expiresInMinutes - The number of minutes until the upload URL expires.
|
|
1868
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.
|
|
1869
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1870
1546
|
* @return {Promise<string>} A promise that resolves to the generated upload URL.
|
|
1871
1547
|
*/
|
|
1872
|
-
static async getUploadUrl(key, expiresInMinutes, bucketName
|
|
1548
|
+
static async getUploadUrl(key, expiresInMinutes, bucketName) {
|
|
1873
1549
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1874
|
-
bucketName
|
|
1875
|
-
objectStorageOptions
|
|
1550
|
+
bucketName
|
|
1876
1551
|
).then((instance) => instance.getUploadUrl(key, expiresInMinutes));
|
|
1877
1552
|
}
|
|
1878
1553
|
/**
|
|
@@ -1882,13 +1557,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1882
1557
|
* @param {FileContent} body - The content of the file to upload.
|
|
1883
1558
|
* @param {Object} [metadata] - Optional metadata to associate with the object.
|
|
1884
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.
|
|
1885
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1886
1560
|
* @return {Promise<UploadResponse>} A promise that resolves to the response of the upload operation.
|
|
1887
1561
|
*/
|
|
1888
|
-
static async upload(key, body, metadata, bucketName
|
|
1562
|
+
static async upload(key, body, metadata, bucketName) {
|
|
1889
1563
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1890
|
-
bucketName
|
|
1891
|
-
objectStorageOptions
|
|
1564
|
+
bucketName
|
|
1892
1565
|
).then((instance) => instance.upload(key, body, metadata));
|
|
1893
1566
|
}
|
|
1894
1567
|
/**
|
|
@@ -1896,13 +1569,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1896
1569
|
*
|
|
1897
1570
|
* @param {string} key - The key of the object to create the upload write stream for.
|
|
1898
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.
|
|
1899
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1900
1572
|
* @return {Promise<CreateUploadWriteStreamResponse>} A promise that resolves to the response of the upload operation.
|
|
1901
1573
|
*/
|
|
1902
|
-
static async createUploadWriteStream(key, bucketName
|
|
1574
|
+
static async createUploadWriteStream(key, bucketName) {
|
|
1903
1575
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1904
|
-
bucketName
|
|
1905
|
-
objectStorageOptions
|
|
1576
|
+
bucketName
|
|
1906
1577
|
).then((instance) => instance.createUploadWriteStream(key));
|
|
1907
1578
|
}
|
|
1908
1579
|
/**
|
|
@@ -1910,13 +1581,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1910
1581
|
*
|
|
1911
1582
|
* @param {string | string[]} key - The key or array of keys of the objects to delete.
|
|
1912
1583
|
* @param {string} [bucketName] - The name of the bucket where the objects are stored. If not provided, the default bucket name will be used.
|
|
1913
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1914
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.
|
|
1915
1585
|
*/
|
|
1916
|
-
static async delete(key, bucketName
|
|
1586
|
+
static async delete(key, bucketName) {
|
|
1917
1587
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1918
|
-
bucketName
|
|
1919
|
-
objectStorageOptions
|
|
1588
|
+
bucketName
|
|
1920
1589
|
).then(async (instance) => {
|
|
1921
1590
|
if (Array.isArray(key)) {
|
|
1922
1591
|
const deleteBlobPromises = key.map(async (blobName) => {
|
|
@@ -1942,13 +1611,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1942
1611
|
* Retrieves the head bucket from the object storage service.
|
|
1943
1612
|
*
|
|
1944
1613
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
1945
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1946
1614
|
* @return {Promise<HeadBucketResponse>} A promise that resolves to the head bucket response.
|
|
1947
1615
|
*/
|
|
1948
|
-
static async getHeadBucket(bucketName
|
|
1616
|
+
static async getHeadBucket(bucketName) {
|
|
1949
1617
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1950
|
-
bucketName
|
|
1951
|
-
objectStorageOptions
|
|
1618
|
+
bucketName
|
|
1952
1619
|
).then((instance) => instance.getHeadBucket());
|
|
1953
1620
|
}
|
|
1954
1621
|
/**
|
|
@@ -1956,13 +1623,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1956
1623
|
*
|
|
1957
1624
|
* @param {string} key - The key of the object to upload.
|
|
1958
1625
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
1959
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1960
1626
|
* @return {Promise<string>} A promise that resolves to the generated upload ID.
|
|
1961
1627
|
*/
|
|
1962
|
-
static async generateUploadIdMultipart(key, bucketName
|
|
1628
|
+
static async generateUploadIdMultipart(key, bucketName) {
|
|
1963
1629
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1964
|
-
bucketName
|
|
1965
|
-
objectStorageOptions
|
|
1630
|
+
bucketName
|
|
1966
1631
|
).then((instance) => instance.generateUploadIdMultipart(key));
|
|
1967
1632
|
}
|
|
1968
1633
|
/**
|
|
@@ -1971,13 +1636,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1971
1636
|
* @param {string} key - The key of the object to retrieve uploads for.
|
|
1972
1637
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
1973
1638
|
* @param {string} [uploadId] - The upload ID to filter the results by.
|
|
1974
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1975
1639
|
* @return {Promise<ListPartsMultipartUploadResponse>} A promise that resolves to the list of multipart uploads for the specified key.
|
|
1976
1640
|
*/
|
|
1977
|
-
static async listMultipartUploadsForKey(key, bucketName, uploadId
|
|
1641
|
+
static async listMultipartUploadsForKey(key, bucketName, uploadId) {
|
|
1978
1642
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1979
|
-
bucketName
|
|
1980
|
-
objectStorageOptions
|
|
1643
|
+
bucketName
|
|
1981
1644
|
).then(
|
|
1982
1645
|
(instance) => instance.listMultipartUploadsForKey(key, uploadId)
|
|
1983
1646
|
);
|
|
@@ -1986,13 +1649,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
1986
1649
|
* Retrieves a list of all multipart uploads for a specified bucket in the object storage service.
|
|
1987
1650
|
*
|
|
1988
1651
|
* @param {string} [bucketName] - The name of the bucket. If not provided, the default bucket name will be used.
|
|
1989
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
1990
1652
|
* @return {Promise<ListMultipartUploadsResponse>} A promise that resolves to the list of multipart uploads for the specified bucket.
|
|
1991
1653
|
*/
|
|
1992
|
-
static async listMultipartUploadsForBucket(bucketName
|
|
1654
|
+
static async listMultipartUploadsForBucket(bucketName) {
|
|
1993
1655
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
1994
|
-
bucketName
|
|
1995
|
-
objectStorageOptions
|
|
1656
|
+
bucketName
|
|
1996
1657
|
).then((instance) => instance.listMultipartUploadsForBucket());
|
|
1997
1658
|
}
|
|
1998
1659
|
/**
|
|
@@ -2003,13 +1664,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
2003
1664
|
* @param {number} partNumber - The number of the part being uploaded.
|
|
2004
1665
|
* @param {string} [uploadId] - The ID of the multipart upload.
|
|
2005
1666
|
* @param {string} [bucketName] - The name of the bucket to upload the file to. If not provided, the default bucket name will be used.
|
|
2006
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
2007
1667
|
* @return {Promise<string>} A Promise that resolves to the base64 encoded block ID of the uploaded part.
|
|
2008
1668
|
*/
|
|
2009
|
-
static async uploadMultipart(key, file, partNumber, uploadId, bucketName
|
|
1669
|
+
static async uploadMultipart(key, file, partNumber, uploadId, bucketName) {
|
|
2010
1670
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2011
|
-
bucketName
|
|
2012
|
-
objectStorageOptions
|
|
1671
|
+
bucketName
|
|
2013
1672
|
).then(
|
|
2014
1673
|
(instance) => instance.uploadMultipart(key, file, partNumber, uploadId)
|
|
2015
1674
|
);
|
|
@@ -2020,13 +1679,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
2020
1679
|
* @param {string} key - The key of the object to complete the multipart upload for.
|
|
2021
1680
|
* @param {string} uploadId - The ID of the multipart upload to complete.
|
|
2022
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.
|
|
2023
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
2024
1682
|
* @return {Promise<void>} A Promise that resolves when the multipart upload is completed.
|
|
2025
1683
|
*/
|
|
2026
|
-
static async completeMultipartUpload(key, uploadId, bucketName
|
|
1684
|
+
static async completeMultipartUpload(key, uploadId, bucketName) {
|
|
2027
1685
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2028
|
-
bucketName
|
|
2029
|
-
objectStorageOptions
|
|
1686
|
+
bucketName
|
|
2030
1687
|
).then((instance) => instance.completeMultipartUpload(key, uploadId));
|
|
2031
1688
|
}
|
|
2032
1689
|
/**
|
|
@@ -2035,13 +1692,11 @@ var ObjectStorageService = class _ObjectStorageService {
|
|
|
2035
1692
|
* @param {string} key - The key of the object to abort the multipart upload for.
|
|
2036
1693
|
* @param {string} uploadId - The ID of the multipart upload to abort.
|
|
2037
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.
|
|
2038
|
-
* @param {ObjectStorageOptions} [objectStorageOptions] - The options for the object storage service.
|
|
2039
1695
|
* @return {Promise<void>} A Promise that resolves when the multipart upload is aborted.
|
|
2040
1696
|
*/
|
|
2041
|
-
static async abortMultipartUpload(key, uploadId, bucketName
|
|
1697
|
+
static async abortMultipartUpload(key, uploadId, bucketName) {
|
|
2042
1698
|
return _ObjectStorageService.getObjectStorageServiceInstance(
|
|
2043
|
-
bucketName
|
|
2044
|
-
objectStorageOptions
|
|
1699
|
+
bucketName
|
|
2045
1700
|
).then((instance) => instance.abortMultipartUpload(key, uploadId));
|
|
2046
1701
|
}
|
|
2047
1702
|
/**
|