@travetto/model-s3 5.0.0-rc.13 → 5.0.0-rc.15
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 +4 -4
- package/src/service.ts +5 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-s3",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.15",
|
|
4
4
|
"description": "S3 backing for the travetto model module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"s3",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@aws-sdk/client-s3": "^3.631.0",
|
|
29
29
|
"@aws-sdk/credential-provider-ini": "^3.609.0",
|
|
30
|
-
"@travetto/config": "^5.0.0-rc.
|
|
31
|
-
"@travetto/model": "^5.0.0-rc.
|
|
30
|
+
"@travetto/config": "^5.0.0-rc.13",
|
|
31
|
+
"@travetto/model": "^5.0.0-rc.14"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@travetto/command": "^5.0.0-rc.
|
|
34
|
+
"@travetto/command": "^5.0.0-rc.12"
|
|
35
35
|
},
|
|
36
36
|
"peerDependenciesMeta": {
|
|
37
37
|
"@travetto/command": {
|
package/src/service.ts
CHANGED
|
@@ -8,12 +8,12 @@ import { NodeHttpHandler } from '@smithy/node-http-handler';
|
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
10
|
ModelCrudSupport, ModelStorageSupport, ModelType, ModelRegistry, ExistsError, NotFoundError, OptionalId,
|
|
11
|
-
ModelBlobSupport
|
|
11
|
+
ModelBlobSupport
|
|
12
12
|
} from '@travetto/model';
|
|
13
13
|
import { Injectable } from '@travetto/di';
|
|
14
14
|
import { Class, AppError, castTo, asFull, BlobMeta, ByteRange, BinaryInput, BinaryUtil } from '@travetto/runtime';
|
|
15
15
|
|
|
16
|
-
import { MODEL_BLOB,
|
|
16
|
+
import { MODEL_BLOB, ModelBlobUtil } from '@travetto/model/src/internal/service/blob';
|
|
17
17
|
import { ModelCrudUtil } from '@travetto/model/src/internal/service/crud';
|
|
18
18
|
import { ModelExpirySupport } from '@travetto/model/src/service/expiry';
|
|
19
19
|
import { ModelExpiryUtil } from '@travetto/model/src/internal/service/expiry';
|
|
@@ -295,15 +295,11 @@ export class S3ModelService implements ModelCrudSupport, ModelBlobSupport, Model
|
|
|
295
295
|
}
|
|
296
296
|
|
|
297
297
|
// Blob support
|
|
298
|
-
async
|
|
299
|
-
await this.describeBlob(location)
|
|
300
|
-
|
|
301
|
-
throw new ExistsError(ModelBlobNamespace, location);
|
|
298
|
+
async upsertBlob(location: string, input: BinaryInput, meta?: BlobMeta, overwrite = true): Promise<void> {
|
|
299
|
+
if (!overwrite && await this.describeBlob(location).then(() => true, () => false)) {
|
|
300
|
+
return;
|
|
302
301
|
}
|
|
303
|
-
return this.upsertBlob(location, input, meta);
|
|
304
|
-
}
|
|
305
302
|
|
|
306
|
-
async upsertBlob(location: string, input: BinaryInput, meta?: BlobMeta): Promise<void> {
|
|
307
303
|
const [stream, blobMeta] = await ModelBlobUtil.getInput(input, meta);
|
|
308
304
|
|
|
309
305
|
if (blobMeta.size && blobMeta.size < this.config.chunkSize) { // If smaller than chunk size
|