@tc-libs/storage 3.14.0 → 4.0.0
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/package.json +3 -3
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/index.js.map +1 -1
- package/README.md +0 -96
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tc-libs/storage",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@tc-libs/constant": "
|
|
5
|
+
"@tc-libs/constant": "4.0.0",
|
|
6
6
|
"jsonc-eslint-parser": "2.4.0",
|
|
7
7
|
"@aws-sdk/client-s3": "^3.779.0",
|
|
8
8
|
"@faker-js/faker": "^9.6.0",
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
"type": "commonjs",
|
|
16
16
|
"main": "./src/index.js",
|
|
17
17
|
"typings": "./src/index.d.ts",
|
|
18
|
-
"types": "
|
|
18
|
+
"types": "./../packages/storage/src/index.d.ts"
|
|
19
19
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './serializations/storage.multipart.serialization';
|
|
2
2
|
export * from './serializations/storage.serialization';
|
|
3
3
|
export * from './storage.module';
|
|
4
|
+
export * from './storage.module.options';
|
|
4
5
|
export * from './storage.types';
|
|
5
6
|
export * from './services/aws-s3/storage.aws-s3.service';
|
|
6
7
|
export * from './constants/acl.enum';
|
package/src/index.js
CHANGED
|
@@ -4,6 +4,7 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
tslib_1.__exportStar(require("./serializations/storage.multipart.serialization"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./serializations/storage.serialization"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./storage.module"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./storage.module.options"), exports);
|
|
7
8
|
tslib_1.__exportStar(require("./storage.types"), exports);
|
|
8
9
|
tslib_1.__exportStar(require("./services/aws-s3/storage.aws-s3.service"), exports);
|
|
9
10
|
tslib_1.__exportStar(require("./constants/acl.enum"), exports);
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/storage/src/index.ts"],"names":[],"mappings":";;;AAAA,2FAAiE;AACjE,iFAAuD;AACvD,2DAAiC;AACjC,0DAAgC;AAChC,mFAAyD;AACzD,+DAAqC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/storage/src/index.ts"],"names":[],"mappings":";;;AAAA,2FAAiE;AACjE,iFAAuD;AACvD,2DAAiC;AACjC,mEAAyC;AACzC,0DAAgC;AAChC,mFAAyD;AACzD,+DAAqC"}
|
package/README.md
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# @tc-libs/storage
|
|
2
|
-
|
|
3
|
-
Astrazione storage file con implementazione principale AWS S3.
|
|
4
|
-
|
|
5
|
-
Il package espone:
|
|
6
|
-
|
|
7
|
-
- `StorageModule`
|
|
8
|
-
- `StorageAwsS3Service`
|
|
9
|
-
- tipi e serializzazioni per upload/download/listing
|
|
10
|
-
- enum ACL
|
|
11
|
-
|
|
12
|
-
## Registrazione
|
|
13
|
-
|
|
14
|
-
```ts
|
|
15
|
-
StorageModule.register(
|
|
16
|
-
{
|
|
17
|
-
aws: {
|
|
18
|
-
credential: {
|
|
19
|
-
key: process.env.AWS_ACCESS_KEY_ID!,
|
|
20
|
-
secret: process.env.AWS_SECRET_ACCESS_KEY!,
|
|
21
|
-
},
|
|
22
|
-
s3: {
|
|
23
|
-
region: process.env.AWS_REGION!,
|
|
24
|
-
bucket: process.env.AWS_S3_BUCKET!,
|
|
25
|
-
baseUrl: process.env.AWS_S3_BASE_URL!,
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
true,
|
|
30
|
-
);
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## Operazioni principali
|
|
34
|
-
|
|
35
|
-
`StorageAwsS3Service` implementa `IStorageService` e copre:
|
|
36
|
-
|
|
37
|
-
- health check bucket
|
|
38
|
-
- lista bucket
|
|
39
|
-
- lista file con prefisso
|
|
40
|
-
- download file e signed URL
|
|
41
|
-
- upload singolo
|
|
42
|
-
- multipart upload
|
|
43
|
-
- delete singolo/multiplo/cartella
|
|
44
|
-
|
|
45
|
-
Esempi:
|
|
46
|
-
|
|
47
|
-
```ts
|
|
48
|
-
const uploaded = await this.storage.uploadItem('avatar.png', buffer, {
|
|
49
|
-
path: 'users/42',
|
|
50
|
-
mime: 'image/png',
|
|
51
|
-
acl: ACL.public_read,
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const signedUrl = await this.storage.getSignedUrl('avatar.png', 'users/42');
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Multipart:
|
|
58
|
-
|
|
59
|
-
```ts
|
|
60
|
-
const init = await this.storage.createMultiPart('video.mp4', {
|
|
61
|
-
path: 'uploads',
|
|
62
|
-
mime: 'video/mp4',
|
|
63
|
-
});
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Serializzazioni utili
|
|
67
|
-
|
|
68
|
-
- `StorageFileSerialization`
|
|
69
|
-
- `StorageFileResponseSerialization`
|
|
70
|
-
- `StorageMultipartSerialization`
|
|
71
|
-
- `StorageMultipartPartsSerialization`
|
|
72
|
-
|
|
73
|
-
Sono utili come tipi di ritorno e per documentazione Swagger.
|
|
74
|
-
|
|
75
|
-
## Note operative
|
|
76
|
-
|
|
77
|
-
- L'implementazione exportata e AWS S3; il file Azure esiste ma non e esportato dall'entrypoint.
|
|
78
|
-
- Il service esegue retry interni sul client S3.
|
|
79
|
-
- `getTextFromFile` forza `text/plain` ed e utile per leggere file testuali.
|
|
80
|
-
|
|
81
|
-
## Export pubblici
|
|
82
|
-
|
|
83
|
-
```ts
|
|
84
|
-
import {
|
|
85
|
-
ACL,
|
|
86
|
-
StorageAwsS3Service,
|
|
87
|
-
StorageModule,
|
|
88
|
-
} from '@tc-libs/storage';
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
## Sviluppo
|
|
92
|
-
|
|
93
|
-
```bash
|
|
94
|
-
nx build storage
|
|
95
|
-
nx test storage
|
|
96
|
-
```
|