@sparkvault/sdk-js 11.2.0 → 11.2.1

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/dist/index.cjs CHANGED
@@ -16318,10 +16318,9 @@ class IngotsModule {
16318
16318
  throw new ValidationError('Provide folder or folderId, not both');
16319
16319
  }
16320
16320
  const name = options.name ?? getBlobName(options.file);
16321
- const contentType = options.contentType ?? options.file.type ?? 'application/octet-stream';
16322
16321
  const created = await this.requestUploadSession(vault, {
16323
16322
  name,
16324
- content_type: contentType,
16323
+ content_type: sentContentType(options),
16325
16324
  size_bytes: options.file.size,
16326
16325
  contentHmac: options.contentHmac,
16327
16326
  folder: options.folder,
@@ -16343,10 +16342,11 @@ class IngotsModule {
16343
16342
  const vaultId = requireVaultId(vault);
16344
16343
  const id = requireResourceId(ingotId, 'ingotId');
16345
16344
  const name = options.name ?? getBlobName(options.file);
16346
- const contentType = options.contentType ?? options.file.type ?? 'application/octet-stream';
16345
+ const contentType = sentContentType(options);
16347
16346
  const response = await this.http.put(apiPath `/v1/vaults/${vaultId}/ingots/${id}`, {
16348
16347
  name,
16349
- content_type: contentType,
16348
+ // Omitted, Core keeps the ingot's stored type (ReplaceIngotOptions.contentType).
16349
+ ...(contentType !== undefined && { content_type: contentType }),
16350
16350
  size_bytes: options.file.size,
16351
16351
  ...(options.contentHmac && { content_hmac: options.contentHmac }),
16352
16352
  }, { vat: vault.vatToken }).catch((error) => {
@@ -16626,7 +16626,8 @@ class IngotsModule {
16626
16626
  async requestUploadSession(vault, body) {
16627
16627
  const payload = {
16628
16628
  name: body.name,
16629
- content_type: body.content_type ?? 'application/octet-stream',
16629
+ // Omitted, Core types the file by its name's extension.
16630
+ ...(body.content_type !== undefined && { content_type: body.content_type }),
16630
16631
  size_bytes: body.size_bytes,
16631
16632
  };
16632
16633
  // folder_path (find-or-create) and folder_id (existing folder) are
@@ -16684,6 +16685,15 @@ function getBlobName(file) {
16684
16685
  }
16685
16686
  return 'unnamed';
16686
16687
  }
16688
+ /**
16689
+ * The type an upload or replacement sends: the caller's, else the file's own.
16690
+ * A Blob of no type reports '', so such a file is sent with none, which Core
16691
+ * reads as a create typed by its name and a replacement that keeps the
16692
+ * ingot's stored type.
16693
+ */
16694
+ function sentContentType(options) {
16695
+ return options.contentType ?? (options.file.type || undefined);
16696
+ }
16687
16697
  function mapIngot(wire) {
16688
16698
  return {
16689
16699
  id: wire.ingot_id,
@@ -17420,7 +17430,7 @@ class SparkVault {
17420
17430
  }
17421
17431
  /** Get the SDK version */
17422
17432
  static get version() {
17423
- return '11.2.0';
17433
+ return '11.2.1';
17424
17434
  }
17425
17435
  }
17426
17436
  if (typeof window !== 'undefined') {