-2

The Larger Context: I am attaching a file to a Confluence page. This is done by POSTing a multi-part request, containing the file, to the Confluence RESTful API.

I'm looking for a simple means of loading a complete binary file (a PNG) into a Blob, so that I can compose the FormData object. The file is small, (less than a Meg) so I am content to load it all into memory.

I can compose the Blob from byte literals, but cannot see yet how I can load file data into it.

Martin Cowie
  • 2,788
  • 7
  • 38
  • 74

1 Answers1

0

The answer came to be shortly after.

    const fileBytes = await Deno.readFile(filename);
    const fileBlob = new Blob([fileBytes], {type: 'image/png'});
Martin Cowie
  • 2,788
  • 7
  • 38
  • 74