Today, we are introducing Persistent Storage and up to 97% faster cold start times for Edge Functions. Previously, Edge Functions only supported ephemeral file storage by writing to /tmp directory. Many common libraries for performing tasks, such as zipping/unzipping files and image transformations, are built to work with persistent file storage, so making them work with Edge Functions required extra steps.

The persistent storage option is built on top of the S3 protocol. It allows you to mount any S3-compatible bucket, including Supabase Storage Buckets, as a directory for your Edge Functions. You can perform operations such as reading and writing files to the mounted buckets as you would in a POSIX file system.

_10// read from S3 bucket_10const data = await Deno.readFile('/s3/my-bucket/results.csv')_10_10// make a directory_10await Deno.mkdir('/s3/my-bucket/sub-dir')_10_10// write to S3 bucket_10await Deno.writeTextFile('/s3/my-bucket/demo.txt', 'hello world')

To access an S3 bucket from Edge Functions, you must set the following as environment variables in Edge Function Secrets.

S3FS_ENDPOINT_URL