createUpload fails with 'Missing Filename'

Thanks @roger - appreciate the response.

The files are coming from formdata and so the ‘name’ property is reserved for the field name and the name of the file ends up in ‘filename’. As per below the file name is coming through just time to the createUpload function.

The tip for logging the body is useful. when I do that I get the below. It looks like filename is definitely being passed in and so is the blob.

Here’s the output in the terminal:

error Error: Missing filename, please provide it as an option!
    at uploadFileOrBlobAndReturnPath (/Users/timchesney/sites/paererewa/node_modules/@datocms/cma-client-browser/src/utils/uploadFileOrBlobAndReturnPath.ts:38:11)
    at Upload.<anonymous> (/Users/timchesney/sites/paererewa/node_modules/@datocms/cma-client-browser/src/resources/Upload.ts:49:54)
    at step (/Users/timchesney/sites/paererewa/node_modules/@datocms/cma-client-browser/dist/cjs/resources/Upload.js:59:23)
    at Object.next (/Users/timchesney/sites/paererewa/node_modules/@datocms/cma-client-browser/dist/cjs/resources/Upload.js:40:53)
    at /Users/timchesney/sites/paererewa/node_modules/@datocms/cma-client-browser/dist/cjs/resources/Upload.js:34:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/timchesney/sites/paererewa/node_modules/@datocms/cma-client-browser/dist/cjs/resources/Upload.js:30:12)
    at <anonymous> (/Users/timchesney/sites/paererewa/node_modules/@datocms/cma-client-browser/src/resources/Upload.ts:42:7)
    at <anonymous> (/Users/timchesney/sites/paererewa/node_modules/@datocms/rest-client-utils/src/makeCancelablePromise.ts:32:11)
    at new Promise (<anonymous>)
{
  name: 'file',
  filename: 'ScreenShot 2024-03-04 at 10.11.28@2x.png',
  type: 'image/png',
  data: <Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 0a 02 00 00 02 5e 08 06 00 00 00 7c ca 8c 05 00 00 00 01 73 52 47 42 00 ae ce 1c e9 00 00 00 96 ... 187335 more bytes>
}

The second half of that is the new logging of the body of the request. Which looks pretty good to me.

To test this another way I tried using the same library in the browser. I was able to create an upload when I used the File directly from the file field, but when I converted this to a blob and tried to upload it I got the same error even when providing filename.

Does the createUpload function definitely support blobs - perhaps there is a bug here? I know that option is called fileOrBlob but it doesn’t seem to like Blobs very much!