@travetto/model-s3 5.0.19 → 5.1.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 +7 -7
- package/src/service.ts +7 -4
- package/LICENSE +0 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-s3",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "S3 backing for the travetto model module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"s3",
|
|
@@ -21,16 +21,16 @@
|
|
|
21
21
|
],
|
|
22
22
|
"main": "__index__.ts",
|
|
23
23
|
"repository": {
|
|
24
|
-
"url": "https://github.com/travetto/travetto.git",
|
|
24
|
+
"url": "git+https://github.com/travetto/travetto.git",
|
|
25
25
|
"directory": "module/model-s3"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aws-sdk/client-s3": "^3.
|
|
28
|
+
"@aws-sdk/client-s3": "^3.731.1",
|
|
29
29
|
"@aws-sdk/credential-provider-ini": "^3.713.0",
|
|
30
|
-
"@aws-sdk/s3-request-presigner": "^3.
|
|
31
|
-
"@travetto/cli": "^5.0
|
|
32
|
-
"@travetto/config": "^5.0
|
|
33
|
-
"@travetto/model": "^5.0
|
|
30
|
+
"@aws-sdk/s3-request-presigner": "^3.731.1",
|
|
31
|
+
"@travetto/cli": "^5.1.0",
|
|
32
|
+
"@travetto/config": "^5.1.0",
|
|
33
|
+
"@travetto/model": "^5.1.0"
|
|
34
34
|
},
|
|
35
35
|
"travetto": {
|
|
36
36
|
"displayName": "S3 Model Support"
|
package/src/service.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
|
-
import { text as toText } from 'node:stream/consumers';
|
|
2
|
+
import { text as toText, buffer as toBuffer } from 'node:stream/consumers';
|
|
3
3
|
import { Agent } from 'node:https';
|
|
4
4
|
|
|
5
5
|
import { S3, CompletedPart, type CreateMultipartUploadRequest, GetObjectCommand, PutObjectCommand } from '@aws-sdk/client-s3';
|
|
@@ -42,8 +42,9 @@ export class S3ModelService implements ModelCrudSupport, ModelBlobSupport, Model
|
|
|
42
42
|
|
|
43
43
|
idSource = ModelCrudUtil.uuidSource();
|
|
44
44
|
client: S3;
|
|
45
|
+
config: S3ModelConfig;
|
|
45
46
|
|
|
46
|
-
constructor(
|
|
47
|
+
constructor(config: S3ModelConfig) { this.config = config; }
|
|
47
48
|
|
|
48
49
|
#getMetaBase({ range, size, ...meta }: BlobMeta): MetaBase {
|
|
49
50
|
return {
|
|
@@ -245,9 +246,11 @@ export class S3ModelService implements ModelCrudSupport, ModelBlobSupport, Model
|
|
|
245
246
|
if (preStore) {
|
|
246
247
|
prepped = await ModelCrudUtil.preStore(cls, item, this);
|
|
247
248
|
}
|
|
249
|
+
const content = Buffer.from(JSON.stringify(prepped), 'utf8');
|
|
248
250
|
await this.client.putObject(this.#q(cls, prepped.id, {
|
|
249
|
-
Body:
|
|
251
|
+
Body: content,
|
|
250
252
|
ContentType: 'application/json',
|
|
253
|
+
ContentLength: content.length,
|
|
251
254
|
...this.#getExpiryConfig(cls, prepped)
|
|
252
255
|
}));
|
|
253
256
|
return prepped;
|
|
@@ -320,7 +323,7 @@ export class S3ModelService implements ModelCrudSupport, ModelBlobSupport, Model
|
|
|
320
323
|
if (blobMeta.size && blobMeta.size < this.config.chunkSize) { // If smaller than chunk size
|
|
321
324
|
// Upload to s3
|
|
322
325
|
await this.client.putObject(this.#q(MODEL_BLOB, location, {
|
|
323
|
-
Body: stream,
|
|
326
|
+
Body: await toBuffer(stream),
|
|
324
327
|
ContentLength: blobMeta.size,
|
|
325
328
|
...this.#getMetaBase(blobMeta),
|
|
326
329
|
}));
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 ArcSine Technologies
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|