@travetto/model-s3 5.0.0-rc.11 → 5.0.0-rc.12

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/service.ts +5 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model-s3",
3
- "version": "5.0.0-rc.11",
3
+ "version": "5.0.0-rc.12",
4
4
  "description": "S3 backing for the travetto model module.",
5
5
  "keywords": [
6
6
  "s3",
package/src/service.ts CHANGED
@@ -44,7 +44,7 @@ export class S3ModelService implements ModelCrudSupport, ModelBlobSupport, Model
44
44
 
45
45
  constructor(public readonly config: S3ModelConfig) { }
46
46
 
47
- #getMetaBase({ range, ...meta }: BlobMeta): MetaBase {
47
+ #getMetaBase({ range, size, ...meta }: BlobMeta): MetaBase {
48
48
  return {
49
49
  ContentType: meta.contentType,
50
50
  ...(meta.contentEncoding ? { ContentEncoding: meta.contentEncoding } : {}),
@@ -52,7 +52,7 @@ export class S3ModelService implements ModelCrudSupport, ModelBlobSupport, Model
52
52
  ...(meta.cacheControl ? { CacheControl: meta.cacheControl } : {}),
53
53
  Metadata: {
54
54
  ...meta,
55
- size: `${meta.size}`
55
+ ...(size ? { size: `${size}` } : {})
56
56
  }
57
57
  };
58
58
  }
@@ -128,8 +128,9 @@ export class S3ModelService implements ModelCrudSupport, ModelBlobSupport, Model
128
128
  };
129
129
  try {
130
130
  for await (const chunk of input) {
131
- buffers.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
132
- total += chunk.length;
131
+ const chunked = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
132
+ buffers.push(chunked);
133
+ total += chunked.length;
133
134
  if (total > this.config.chunkSize) {
134
135
  await flush();
135
136
  }