'How to read and send static images using Cloudflare worker?

I want to serve static images stored in the root directory of the Cloudflare script.

I tried using

const res = await fetch('./image.png');
const data = await res.blob();

but it isn't working.

There's no file system fs like that we have in Node for reading the static files here.

My aim is to serve dynamically generated images using Cloudflare workers.

Any help is highly appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source