ZidanZ
Denoβ€’3y agoβ€’
9 replies
Zidan

Closing a file

How do I close a file after opening and streaming it?
My handler function code is as follows:
return new Promise(
  (grant) => {
    Deno.open(
      asset.path
    ).then(
      (file) => {
        grant(
          new Response(
            file.readable,
            {
              status: 200,
              headers: {
                "content-type": asset.type,
                "content-length": file.stat.size.toString()
              }
            }
          )
        )
      }
    )
  }
);

Is there a good way of closing the "file" after returning the "Response" object?
Was this page helpful?