@travetto/model-s3 8.0.0-alpha.20 → 8.0.0-alpha.21

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/README.md CHANGED
@@ -67,6 +67,7 @@ export class S3ModelConfig {
67
67
  /**
68
68
  * Provide base URL for public access
69
69
  */
70
+ @Url()
70
71
  @Required(false)
71
72
  publicBaseUrl: string;
72
73
 
@@ -81,25 +82,13 @@ export class S3ModelConfig {
81
82
  }
82
83
 
83
84
  if (!this.publicBaseUrl) {
84
- if (this.endpoint) {
85
- if (this.endpoint.includes('localhost')) {
86
- this.publicBaseUrl = this.endpoint;
87
- } else {
88
- try {
89
- this.publicBaseUrl = new URL(this.endpoint).origin;
90
- } catch {
91
- this.publicBaseUrl = this.endpoint;
92
- }
93
- }
85
+ if (this.endpoint?.includes('localhost')) {
86
+ this.publicBaseUrl = this.endpoint;
94
87
  } else {
95
88
  this.publicBaseUrl = `https://${this.bucket}.s3.amazonaws.com`;
96
89
  }
97
90
  }
98
91
 
99
- if (this.publicBaseUrl && !this.publicBaseUrl.includes('://')) {
100
- this.publicBaseUrl = `https://${this.publicBaseUrl}`;
101
- }
102
-
103
92
  if (!this.accessKeyId && !this.secretAccessKey) {
104
93
  const creds = await fromIni({ profile: this.profile })();
105
94
  this.accessKeyId = creds.accessKeyId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model-s3",
3
- "version": "8.0.0-alpha.20",
3
+ "version": "8.0.0-alpha.21",
4
4
  "type": "module",
5
5
  "description": "S3 backing for the travetto model module.",
6
6
  "keywords": [
package/src/service.ts CHANGED
@@ -22,7 +22,7 @@ function isMetadataBearer(value: unknown): value is MetadataBearer {
22
22
  return !!value && typeof value === 'object' && '$metadata' in value;
23
23
  }
24
24
 
25
- function hasContentType<T>(value: T): value is T & { contenttype?: string } {
25
+ function hasLowerContentType<T>(value: T): value is T & { contenttype?: string } {
26
26
  return value !== undefined && value !== null && Object.hasOwn(value, 'contenttype');
27
27
  }
28
28
 
@@ -361,7 +361,7 @@ export class S3ModelService implements ModelCrudSupport, ModelBlobSupport, Model
361
361
  return BinaryMetadataUtil.makeBlob(() => this.#getObject(location, final), { ...metadata, range: final });
362
362
  }
363
363
 
364
- async headBlob(location: string): Promise<{ Metadata?: BinaryMetadata, ContentLength?: number }> {
364
+ async headBlob(location: string): Promise<{ Metadata?: BinaryMetadata, ContentLength?: number, ContentType?: string }> {
365
365
  const query = this.#queryBlob(location);
366
366
  try {
367
367
  return (await this.client.headObject(query));
@@ -380,11 +380,11 @@ export class S3ModelService implements ModelCrudSupport, ModelBlobSupport, Model
380
380
 
381
381
  if (blob) {
382
382
  const metadata: BinaryMetadata = {
383
- contentType: '',
383
+ contentType: blob.ContentType ?? '',
384
384
  ...blob.Metadata,
385
385
  size: blob.ContentLength!,
386
386
  };
387
- if (hasContentType(metadata)) {
387
+ if (hasLowerContentType(metadata)) {
388
388
  metadata['contentType'] = metadata['contenttype']!;
389
389
  delete metadata['contenttype'];
390
390
  }