mnemospark 0.9.1 → 0.9.2

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.js CHANGED
@@ -4854,7 +4854,7 @@ function presignedPutBodyInit(encryptedContent, encryptedTempPath) {
4854
4854
  }
4855
4855
  throw new Error("Cannot upload storage object: missing encrypted payload body.");
4856
4856
  }
4857
- async function uploadPresignedObjectIfNeeded(uploadResponse, uploadMode, encryptedContent, encryptedTempPath, fetchImpl = fetch) {
4857
+ async function uploadPresignedObjectIfNeeded(uploadResponse, uploadMode, encryptedContent, encryptedTempPath, fetchImpl = fetch, presignedStreamContentLengthBytes) {
4858
4858
  if (!uploadResponse.upload_url) {
4859
4859
  if (uploadMode === "presigned") {
4860
4860
  throw new Error("Cannot upload storage object: missing presigned upload URL.");
@@ -4865,6 +4865,12 @@ async function uploadPresignedObjectIfNeeded(uploadResponse, uploadMode, encrypt
4865
4865
  if (!headers.has("content-type")) {
4866
4866
  headers.set("content-type", "application/octet-stream");
4867
4867
  }
4868
+ if (encryptedTempPath?.trim()) {
4869
+ const len = presignedStreamContentLengthBytes ?? (await stat2(encryptedTempPath.trim())).size;
4870
+ if (!headers.has("content-length")) {
4871
+ headers.set("content-length", String(len));
4872
+ }
4873
+ }
4868
4874
  const { body, duplex } = presignedPutBodyInit(encryptedContent, encryptedTempPath);
4869
4875
  const firstInit = {
4870
4876
  method: "PUT",
@@ -6421,7 +6427,8 @@ operation-id: ${operationId}`,
6421
6427
  preparedPayload.payload.mode,
6422
6428
  preparedPayload.encryptedContent,
6423
6429
  preparedPayload.encryptedTempPath,
6424
- fetchImpl
6430
+ fetchImpl,
6431
+ preparedPayload.encryptedTempPath ? preparedPayload.payload.content_length_bytes : void 0
6425
6432
  );
6426
6433
  let finalizedUploadResponse = uploadResponse;
6427
6434
  if (preparedPayload.payload.mode === "presigned" && uploadResponse.confirmation_required === true) {