@golemio/core 1.2.20-dev.658730114 → 1.2.21-dev.663558633
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/helpers/data-access/storage/AbstractStorageService.d.ts +2 -0
- package/dist/helpers/data-access/storage/AbstractStorageService.js.map +1 -1
- package/dist/helpers/data-access/storage/AzureBlobStorageService.d.ts +3 -1
- package/dist/helpers/data-access/storage/AzureBlobStorageService.js +28 -2
- package/dist/helpers/data-access/storage/AzureBlobStorageService.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
export declare abstract class AbstractStorageService {
|
|
3
3
|
abstract uploadFile(data: Buffer | string, pathPrefix: string, ext?: string, fileName?: string): Promise<void>;
|
|
4
|
+
abstract deleteFile(key: string): Promise<void>;
|
|
5
|
+
abstract getFileStream(fileKey: string): Promise<NodeJS.ReadableStream | undefined>;
|
|
4
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractStorageService.js","sourceRoot":"","sources":["../../../../src/helpers/data-access/storage/AbstractStorageService.ts"],"names":[],"mappings":";;;AAAA,MAAsB,sBAAsB;
|
|
1
|
+
{"version":3,"file":"AbstractStorageService.js","sourceRoot":"","sources":["../../../../src/helpers/data-access/storage/AbstractStorageService.ts"],"names":[],"mappings":";;;AAAA,MAAsB,sBAAsB;CAI3C;AAJD,wDAIC"}
|
|
@@ -6,9 +6,11 @@ export interface IAzureBlobStorageConfig {
|
|
|
6
6
|
containerName: string;
|
|
7
7
|
}
|
|
8
8
|
export declare class AzureBlobStorageService extends AbstractStorageService {
|
|
9
|
-
private readonly containerClient;
|
|
10
9
|
private readonly log;
|
|
10
|
+
private readonly containerClient;
|
|
11
11
|
constructor(config: IAzureBlobStorageConfig, log: ILogger);
|
|
12
12
|
uploadFile(data: Buffer | string, pathPrefix: string, ext?: string, fileName?: string): Promise<void>;
|
|
13
|
+
deleteFile(fileKey: string): Promise<void>;
|
|
14
|
+
getFileStream(fileKey: string): Promise<NodeJS.ReadableStream | undefined>;
|
|
13
15
|
private handleUploadProgress;
|
|
14
16
|
}
|
|
@@ -16,13 +16,13 @@ const AbstractStorageService_1 = require("./AbstractStorageService");
|
|
|
16
16
|
class AzureBlobStorageService extends AbstractStorageService_1.AbstractStorageService {
|
|
17
17
|
constructor(config, log) {
|
|
18
18
|
super();
|
|
19
|
+
this.log = log;
|
|
19
20
|
const blobServiceClient = storage_blob_1.BlobServiceClient.fromConnectionString(config.connectionString);
|
|
20
21
|
this.containerClient = blobServiceClient.getContainerClient(config.containerName);
|
|
21
22
|
this.containerClient.createIfNotExists().catch((err) => {
|
|
22
23
|
// This is fine in the production environment
|
|
23
|
-
log.debug(`[${this.constructor.name}] Could not initialize container "${config.containerName}"`, err);
|
|
24
|
+
this.log.debug(`[${this.constructor.name}] Could not initialize container "${config.containerName}"`, err);
|
|
24
25
|
});
|
|
25
|
-
this.log = log;
|
|
26
26
|
}
|
|
27
27
|
uploadFile(data, pathPrefix, ext = "", fileName) {
|
|
28
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -46,6 +46,32 @@ class AzureBlobStorageService extends AbstractStorageService_1.AbstractStorageSe
|
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
+
deleteFile(fileKey) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
try {
|
|
52
|
+
const options = {
|
|
53
|
+
deleteSnapshots: "include",
|
|
54
|
+
};
|
|
55
|
+
const blobClient = this.containerClient.getBlockBlobClient(fileKey);
|
|
56
|
+
yield blobClient.delete(options);
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
this.log.error(`[${this.constructor.name}] Deletion of data failed (${fileKey})`, err);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
getFileStream(fileKey) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
try {
|
|
66
|
+
const blobClient = this.containerClient.getBlockBlobClient(fileKey);
|
|
67
|
+
const downloadResponse = yield blobClient.download();
|
|
68
|
+
return downloadResponse.readableStreamBody;
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
this.log.error(`[${this.constructor.name}] Getting data failed (${fileKey})`, err);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
49
75
|
handleUploadProgress(filePath, dataByteLength) {
|
|
50
76
|
return (progress) => {
|
|
51
77
|
this.log.verbose(`[${this.constructor.name}] File upload ` + `${filePath}: ${progress.loadedBytes} / ${dataByteLength}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AzureBlobStorageService.js","sourceRoot":"","sources":["../../../../src/helpers/data-access/storage/AzureBlobStorageService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"AzureBlobStorageService.js","sourceRoot":"","sources":["../../../../src/helpers/data-access/storage/AzureBlobStorageService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sDAA4H;AAE5H,iCAAiC;AAEjC,qEAAkE;AAOlE,MAAa,uBAAwB,SAAQ,+CAAsB;IAG/D,YAAY,MAA+B,EAAmB,GAAY;QACtE,KAAK,EAAE,CAAC;QADkD,QAAG,GAAH,GAAG,CAAS;QAGtE,MAAM,iBAAiB,GAAG,gCAAiB,CAAC,oBAAoB,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAC1F,IAAI,CAAC,eAAe,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QAClF,IAAI,CAAC,eAAe,CAAC,iBAAiB,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACnD,6CAA6C;YAC7C,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,qCAAqC,MA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