@spinajs/fs-s3 2.0.170 → 2.0.172
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/lib/cjs/index.d.ts +7 -9
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +76 -77
- package/lib/cjs/index.js.map +1 -1
- package/lib/mjs/index.d.ts +7 -9
- package/lib/mjs/index.d.ts.map +1 -1
- package/lib/mjs/index.js +78 -79
- package/lib/mjs/index.js.map +1 -1
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +7 -6
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
3
|
import { Log } from '@spinajs/log-common';
|
|
5
4
|
import { fs, IStat, IZipResult } from '@spinajs/fs';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
5
|
+
import { S3Client, S3ClientConfig } from '@aws-sdk/client-s3';
|
|
6
|
+
import { ReadStream } from 'fs';
|
|
8
7
|
export interface IS3Config {
|
|
9
8
|
bucket: string;
|
|
10
9
|
name: string;
|
|
@@ -21,9 +20,8 @@ export interface IS3Config {
|
|
|
21
20
|
export declare class fsS3 extends fs {
|
|
22
21
|
Options: IS3Config;
|
|
23
22
|
protected Logger: Log;
|
|
24
|
-
protected S3:
|
|
25
|
-
protected AwsConfig:
|
|
26
|
-
protected ConfigPath: string;
|
|
23
|
+
protected S3: S3Client;
|
|
24
|
+
protected AwsConfig: S3ClientConfig;
|
|
27
25
|
/**
|
|
28
26
|
* File system for temporary files
|
|
29
27
|
*/
|
|
@@ -47,13 +45,13 @@ export declare class fsS3 extends fs {
|
|
|
47
45
|
* read all content of file
|
|
48
46
|
*/
|
|
49
47
|
read(path: string, encoding: BufferEncoding): Promise<string | Buffer>;
|
|
50
|
-
readStream(path: string, encoding?: BufferEncoding): Promise<
|
|
48
|
+
readStream(path: string, encoding?: BufferEncoding): Promise<ReadStream>;
|
|
51
49
|
/**
|
|
52
50
|
* Write to file string or buffer
|
|
53
51
|
*/
|
|
54
52
|
write(path: string, data: string | Buffer, encoding?: BufferEncoding): Promise<void>;
|
|
55
53
|
append(path: string, data: string | Buffer, encoding?: BufferEncoding): Promise<void>;
|
|
56
|
-
writeStream(path: string, encoding?: BufferEncoding): Promise<
|
|
54
|
+
writeStream(path: string, rStream?: ReadStream | BufferEncoding, encoding?: BufferEncoding): Promise<any>;
|
|
57
55
|
/**
|
|
58
56
|
* Checks if file existst
|
|
59
57
|
* @param path - path to check
|
|
@@ -98,7 +96,6 @@ export declare class fsS3 extends fs {
|
|
|
98
96
|
* Returns file statistics, not all fields may be accesible
|
|
99
97
|
*/
|
|
100
98
|
stat(path: string): Promise<IStat>;
|
|
101
|
-
protected getSignedUrl(path: string): Promise<string>;
|
|
102
99
|
tmppath(): string;
|
|
103
100
|
/**
|
|
104
101
|
* List content of directory
|
|
@@ -106,6 +103,7 @@ export declare class fsS3 extends fs {
|
|
|
106
103
|
* @param path - path to directory
|
|
107
104
|
*/
|
|
108
105
|
list(path: string): Promise<string[]>;
|
|
106
|
+
unzip(_path: string, _destPath: string): Promise<void>;
|
|
109
107
|
zip(path: string, zName?: string): Promise<IZipResult>;
|
|
110
108
|
resolvePath(_path: string): string;
|
|
111
109
|
}
|
package/lib/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,GAAG,EAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,QAA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;;OAIG;IACU,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAU5C;;OAEG;IACU,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAKlD;;OAEG;IACU,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAIpD;;;;;OAKG;IACU,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO;IAcpD;;;;;OAKG;IACU,EAAE,CAAC,KAAK,EAAE,MAAM;IAU7B;;;;OAIG;IACU,KAAK;IAIlB;;OAEG;IACU,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAoCxC,OAAO,IAAI,MAAM;IAIxB;;;;OAIG;IACU,IAAI,CAAC,IAAI,EAAE,MAAM;IAWxB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAI/B,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IA6B5D,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;CAG1C"}
|
package/lib/cjs/index.js
CHANGED
|
@@ -16,14 +16,15 @@ exports.fsS3 = void 0;
|
|
|
16
16
|
const di_1 = require("@spinajs/di");
|
|
17
17
|
const log_common_1 = require("@spinajs/log-common");
|
|
18
18
|
const fs_1 = require("@spinajs/fs");
|
|
19
|
-
const
|
|
19
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
20
|
+
const lib_storage_1 = require("@aws-sdk/lib-storage");
|
|
20
21
|
const configuration_1 = require("@spinajs/configuration");
|
|
21
22
|
const archiver_1 = __importDefault(require("archiver"));
|
|
22
23
|
const path_1 = require("path");
|
|
23
24
|
const exceptions_1 = require("@spinajs/exceptions");
|
|
24
25
|
const fs_2 = require("fs");
|
|
25
26
|
const luxon_1 = require("luxon");
|
|
26
|
-
const stream_1 =
|
|
27
|
+
const stream_1 = require("stream");
|
|
27
28
|
/**
|
|
28
29
|
* Abstract layer for file operations.
|
|
29
30
|
* Basic implementation is just wrapper for native node fs functions
|
|
@@ -46,16 +47,7 @@ let fsS3 = class fsS3 extends fs_1.fs {
|
|
|
46
47
|
this.Options = Options;
|
|
47
48
|
}
|
|
48
49
|
async resolve() {
|
|
49
|
-
|
|
50
|
-
aws_sdk_1.default.config.loadFromPath(this.ConfigPath);
|
|
51
|
-
}
|
|
52
|
-
else if (this.AwsConfig) {
|
|
53
|
-
aws_sdk_1.default.config.update(this.AwsConfig);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
throw new exceptions_1.UnexpectedServerError(`Configuraiton for aws s3 filesystem not present. Please set fs.s3.config or fs.s3.confgiPath configuration properties.`);
|
|
57
|
-
}
|
|
58
|
-
this.S3 = new aws_sdk_1.default.S3();
|
|
50
|
+
this.S3 = new client_s3_1.S3Client(this.AwsConfig);
|
|
59
51
|
}
|
|
60
52
|
/**
|
|
61
53
|
*
|
|
@@ -67,22 +59,21 @@ let fsS3 = class fsS3 extends fs_1.fs {
|
|
|
67
59
|
async download(path) {
|
|
68
60
|
const tmpName = this.TempFs.tmppath();
|
|
69
61
|
const wStream = await this.TempFs.writeStream(tmpName);
|
|
62
|
+
const command = new client_s3_1.GetObjectCommand({
|
|
63
|
+
Bucket: this.Options.bucket,
|
|
64
|
+
Key: path,
|
|
65
|
+
});
|
|
66
|
+
const result = await this.S3.send(command);
|
|
70
67
|
return new Promise((resolve, reject) => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
})
|
|
81
|
-
.on('httpDone', () => {
|
|
82
|
-
wStream.end();
|
|
83
|
-
this.Logger.trace(`Downloaded file from S3 bucket ${this.Options.bucket}, file: ${path}`);
|
|
84
|
-
resolve(tmpName);
|
|
85
|
-
});
|
|
68
|
+
if (result.Body instanceof stream_1.Readable) {
|
|
69
|
+
result.Body
|
|
70
|
+
.pipe(wStream)
|
|
71
|
+
.on("error", (err) => reject(err))
|
|
72
|
+
.on("close", () => resolve(tmpName));
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
reject(new exceptions_1.IOFail(`Cannot download file ${path}, empty response`));
|
|
76
|
+
}
|
|
86
77
|
});
|
|
87
78
|
}
|
|
88
79
|
/**
|
|
@@ -102,17 +93,21 @@ let fsS3 = class fsS3 extends fs_1.fs {
|
|
|
102
93
|
* Write to file string or buffer
|
|
103
94
|
*/
|
|
104
95
|
async write(path, data, encoding) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
96
|
+
const upload = new lib_storage_1.Upload({
|
|
97
|
+
client: this.S3,
|
|
98
|
+
params: {
|
|
99
|
+
Bucket: this.Options.bucket,
|
|
100
|
+
Key: path,
|
|
101
|
+
Body: data,
|
|
102
|
+
ContentEncoding: encoding
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
await upload.done();
|
|
111
106
|
}
|
|
112
107
|
async append(path, data, encoding) {
|
|
113
108
|
/**
|
|
114
109
|
* We cannot append to file in s3 directly,
|
|
115
|
-
* we have to download file
|
|
110
|
+
* we have to download file first, append locally, then upload again new file
|
|
116
111
|
*/
|
|
117
112
|
const fLocal = await this.download(path);
|
|
118
113
|
await this.TempFs.append(fLocal, data, encoding);
|
|
@@ -142,19 +137,20 @@ let fsS3 = class fsS3 extends fs_1.fs {
|
|
|
142
137
|
});
|
|
143
138
|
});
|
|
144
139
|
}
|
|
145
|
-
async writeStream(path, encoding) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
140
|
+
async writeStream(path, rStream, encoding) {
|
|
141
|
+
if (!(rStream instanceof fs_2.ReadStream)) {
|
|
142
|
+
throw new exceptions_1.InvalidArgument(`rStream should be readable stream`);
|
|
143
|
+
}
|
|
144
|
+
const result = new lib_storage_1.Upload({
|
|
145
|
+
client: this.S3,
|
|
146
|
+
params: {
|
|
147
|
+
Bucket: this.Options.bucket,
|
|
148
|
+
Key: path,
|
|
149
|
+
Body: rStream,
|
|
150
|
+
ContentEncoding: encoding,
|
|
151
|
+
},
|
|
156
152
|
});
|
|
157
|
-
|
|
153
|
+
await result.done();
|
|
158
154
|
}
|
|
159
155
|
/**
|
|
160
156
|
* Checks if file existst
|
|
@@ -162,15 +158,15 @@ let fsS3 = class fsS3 extends fs_1.fs {
|
|
|
162
158
|
*/
|
|
163
159
|
async exists(path) {
|
|
164
160
|
try {
|
|
165
|
-
|
|
161
|
+
const command = new client_s3_1.HeadObjectCommand({
|
|
166
162
|
Bucket: this.Options.bucket,
|
|
167
163
|
Key: path,
|
|
168
|
-
})
|
|
164
|
+
});
|
|
165
|
+
await this.S3.send(command);
|
|
169
166
|
}
|
|
170
167
|
catch (err) {
|
|
171
|
-
if (err.name === '
|
|
168
|
+
if (err.name === 'NotFound')
|
|
172
169
|
return false;
|
|
173
|
-
}
|
|
174
170
|
}
|
|
175
171
|
return true;
|
|
176
172
|
}
|
|
@@ -185,12 +181,12 @@ let fsS3 = class fsS3 extends fs_1.fs {
|
|
|
185
181
|
* @param dest - dest path
|
|
186
182
|
*/
|
|
187
183
|
async copy(path, dest) {
|
|
188
|
-
const
|
|
184
|
+
const command = new client_s3_1.CopyObjectCommand({
|
|
189
185
|
Bucket: this.Options.bucket,
|
|
190
186
|
CopySource: this.Options.bucket + '/' + path,
|
|
191
187
|
Key: dest,
|
|
192
|
-
};
|
|
193
|
-
await this.S3.
|
|
188
|
+
});
|
|
189
|
+
await this.S3.send(command);
|
|
194
190
|
}
|
|
195
191
|
/**
|
|
196
192
|
* Copy file to another location and deletes src file
|
|
@@ -216,10 +212,11 @@ let fsS3 = class fsS3 extends fs_1.fs {
|
|
|
216
212
|
await this.TempFs.unlink(path);
|
|
217
213
|
return;
|
|
218
214
|
}
|
|
219
|
-
|
|
215
|
+
const command = new client_s3_1.DeleteObjectCommand({
|
|
220
216
|
Key: path,
|
|
221
217
|
Bucket: this.Options.bucket,
|
|
222
|
-
})
|
|
218
|
+
});
|
|
219
|
+
await this.S3.send(command);
|
|
223
220
|
}
|
|
224
221
|
/**
|
|
225
222
|
*
|
|
@@ -227,9 +224,12 @@ let fsS3 = class fsS3 extends fs_1.fs {
|
|
|
227
224
|
*
|
|
228
225
|
* @param path - dir to remove
|
|
229
226
|
*/
|
|
230
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
|
|
231
227
|
async rm(_path) {
|
|
232
|
-
|
|
228
|
+
const command = new client_s3_1.DeleteObjectCommand({
|
|
229
|
+
Bucket: this.Options.bucket,
|
|
230
|
+
Key: _path
|
|
231
|
+
});
|
|
232
|
+
await this.S3.send(command);
|
|
233
233
|
}
|
|
234
234
|
/**
|
|
235
235
|
*
|
|
@@ -243,10 +243,11 @@ let fsS3 = class fsS3 extends fs_1.fs {
|
|
|
243
243
|
* Returns file statistics, not all fields may be accesible
|
|
244
244
|
*/
|
|
245
245
|
async stat(path) {
|
|
246
|
-
const
|
|
246
|
+
const command = new client_s3_1.HeadObjectCommand({
|
|
247
247
|
Bucket: this.Options.bucket,
|
|
248
|
-
Key: path
|
|
249
|
-
})
|
|
248
|
+
Key: path
|
|
249
|
+
});
|
|
250
|
+
const result = await this.S3.send(command);
|
|
250
251
|
return {
|
|
251
252
|
// no directories in s3
|
|
252
253
|
IsDirectory: false,
|
|
@@ -255,18 +256,18 @@ let fsS3 = class fsS3 extends fs_1.fs {
|
|
|
255
256
|
// no creation time
|
|
256
257
|
CreationTime: luxon_1.DateTime.min(),
|
|
257
258
|
ModifiedTime: luxon_1.DateTime.fromJSDate(result.LastModified),
|
|
258
|
-
// no access time in
|
|
259
|
+
// no access time in s3s
|
|
259
260
|
AccessTime: luxon_1.DateTime.min(),
|
|
260
261
|
Size: result.ContentLength,
|
|
261
262
|
};
|
|
262
263
|
}
|
|
263
|
-
async getSignedUrl(path) {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}
|
|
264
|
+
// protected async getSignedUrl(path: string) {
|
|
265
|
+
// return this.S3.getSignedUrlPromise('getObject', {
|
|
266
|
+
// Bucket: this.Options.bucket,
|
|
267
|
+
// Key: path,
|
|
268
|
+
// Expires: 24 * 60 * 60,
|
|
269
|
+
// });
|
|
270
|
+
// }
|
|
270
271
|
tmppath() {
|
|
271
272
|
throw new exceptions_1.MethodNotImplemented('fs s3 does not support temporary paths');
|
|
272
273
|
}
|
|
@@ -276,15 +277,17 @@ let fsS3 = class fsS3 extends fs_1.fs {
|
|
|
276
277
|
* @param path - path to directory
|
|
277
278
|
*/
|
|
278
279
|
async list(path) {
|
|
279
|
-
const
|
|
280
|
+
const command = new client_s3_1.ListObjectsV2Command({
|
|
280
281
|
Bucket: this.Options.bucket,
|
|
281
282
|
Delimiter: '/',
|
|
282
283
|
Prefix: path,
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
const result = await this.S3.listObjectsV2(params).promise();
|
|
284
|
+
});
|
|
285
|
+
const result = await this.S3.send(command);
|
|
286
286
|
return result.Contents.map((x) => x.Key);
|
|
287
287
|
}
|
|
288
|
+
async unzip(_path, _destPath) {
|
|
289
|
+
throw new Error('not implemented');
|
|
290
|
+
}
|
|
288
291
|
async zip(path, zName) {
|
|
289
292
|
const zTmpName = this.TempFs.tmppath();
|
|
290
293
|
const output = await this.TempFs.writeStream(zTmpName);
|
|
@@ -319,12 +322,8 @@ __decorate([
|
|
|
319
322
|
], fsS3.prototype, "Logger", void 0);
|
|
320
323
|
__decorate([
|
|
321
324
|
(0, configuration_1.Config)('fs.s3.config'),
|
|
322
|
-
__metadata("design:type",
|
|
325
|
+
__metadata("design:type", Object)
|
|
323
326
|
], fsS3.prototype, "AwsConfig", void 0);
|
|
324
|
-
__decorate([
|
|
325
|
-
(0, configuration_1.Config)('fs.s3.configPath'),
|
|
326
|
-
__metadata("design:type", String)
|
|
327
|
-
], fsS3.prototype, "ConfigPath", void 0);
|
|
328
327
|
__decorate([
|
|
329
328
|
(0, fs_1.FileSystem)('fs-temp'),
|
|
330
329
|
__metadata("design:type", fs_1.fs)
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oCAA2D;AAC3D,oDAAkD;AAClD,oCAAgE;AAChE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oCAA2D;AAC3D,oDAAkD;AAClD,oCAAgE;AAChE,kDAAiK;AACjK,sDAA8C;AAC9C,0DAAgD;AAChD,wDAAgC;AAChC,+BAAgC;AAChC,oDAAoF;AACpF,2BAAgE;AAChE,iCAAiC;AACjC,mCAAkC;AAOlC;;;;;;;;GAQG;AAGI,IAAM,IAAI,GAAV,MAAM,IAAK,SAAQ,OAAE;IAe1B;;;OAGG;IACH,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED,YAAmB,OAAkB;QACnC,KAAK,EAAE,CAAC;QADS,YAAO,GAAP,OAAO,CAAW;IAErC,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,IAAI,CAAC,EAAE,GAAG,IAAI,oBAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,QAAQ,CAAC,IAAY;QAChC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MA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,CAAC;YACD,QAAQ,EAAE,GAAG,EAAE;gBACb,OAAO,IAAA,iBAAY,EAAC,GAAG,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC;YAC/C,CAAC;SACF,CAAC;IACJ,CAAC;IAED,gEAAgE;IACzD,WAAW,CAAC,KAAa;QAC9B,MAAM,IAAI,iCAAoB,CAAC,uCAAuC,CAAC,CAAC;IAC1E,CAAC;CACF,CAAA;AAzVC;IAAC,IAAA,mBAAM,EAAC,IAAI,CAAC;8BACK,gBAAG;oCAAC;AAItB;IAAC,IAAA,sBAAM,EAAC,cAAc,CAAC;;uCACa;AAKpC;IAAC,IAAA,eAAU,EAAC,SAAS,CAAC;8BACJ,OAAE;oCAAC;AAbV,IAAI;IAFhB,IAAA,eAAU,EAAC,IAAI,CAAC;IAChB,IAAA,qBAAgB,GAAE;;GACN,IAAI,CA0VhB;AA1VY,oBAAI"}
|
package/lib/mjs/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
4
3
|
import { Log } from '@spinajs/log-common';
|
|
5
4
|
import { fs, IStat, IZipResult } from '@spinajs/fs';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
5
|
+
import { S3Client, S3ClientConfig } from '@aws-sdk/client-s3';
|
|
6
|
+
import { ReadStream } from 'fs';
|
|
8
7
|
export interface IS3Config {
|
|
9
8
|
bucket: string;
|
|
10
9
|
name: string;
|
|
@@ -21,9 +20,8 @@ export interface IS3Config {
|
|
|
21
20
|
export declare class fsS3 extends fs {
|
|
22
21
|
Options: IS3Config;
|
|
23
22
|
protected Logger: Log;
|
|
24
|
-
protected S3:
|
|
25
|
-
protected AwsConfig:
|
|
26
|
-
protected ConfigPath: string;
|
|
23
|
+
protected S3: S3Client;
|
|
24
|
+
protected AwsConfig: S3ClientConfig;
|
|
27
25
|
/**
|
|
28
26
|
* File system for temporary files
|
|
29
27
|
*/
|
|
@@ -47,13 +45,13 @@ export declare class fsS3 extends fs {
|
|
|
47
45
|
* read all content of file
|
|
48
46
|
*/
|
|
49
47
|
read(path: string, encoding: BufferEncoding): Promise<string | Buffer>;
|
|
50
|
-
readStream(path: string, encoding?: BufferEncoding): Promise<
|
|
48
|
+
readStream(path: string, encoding?: BufferEncoding): Promise<ReadStream>;
|
|
51
49
|
/**
|
|
52
50
|
* Write to file string or buffer
|
|
53
51
|
*/
|
|
54
52
|
write(path: string, data: string | Buffer, encoding?: BufferEncoding): Promise<void>;
|
|
55
53
|
append(path: string, data: string | Buffer, encoding?: BufferEncoding): Promise<void>;
|
|
56
|
-
writeStream(path: string, encoding?: BufferEncoding): Promise<
|
|
54
|
+
writeStream(path: string, rStream?: ReadStream | BufferEncoding, encoding?: BufferEncoding): Promise<any>;
|
|
57
55
|
/**
|
|
58
56
|
* Checks if file existst
|
|
59
57
|
* @param path - path to check
|
|
@@ -98,7 +96,6 @@ export declare class fsS3 extends fs {
|
|
|
98
96
|
* Returns file statistics, not all fields may be accesible
|
|
99
97
|
*/
|
|
100
98
|
stat(path: string): Promise<IStat>;
|
|
101
|
-
protected getSignedUrl(path: string): Promise<string>;
|
|
102
99
|
tmppath(): string;
|
|
103
100
|
/**
|
|
104
101
|
* List content of directory
|
|
@@ -106,6 +103,7 @@ export declare class fsS3 extends fs {
|
|
|
106
103
|
* @param path - path to directory
|
|
107
104
|
*/
|
|
108
105
|
list(path: string): Promise<string[]>;
|
|
106
|
+
unzip(_path: string, _destPath: string): Promise<void>;
|
|
109
107
|
zip(path: string, zName?: string): Promise<IZipResult>;
|
|
110
108
|
resolvePath(_path: string): string;
|
|
111
109
|
}
|
package/lib/mjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.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