Briefly - Simple, robust temporary file support

Highlighted Features

  • Create temporary files with prefix and extname options.
  • Files are removed after the requesting process exits.
  • File creation is based on Plug.Upload’s robust retry logic.
  • Configurable; built-in support for system environment variables and fallbacks.

Use Briefly to create a temporary file:

{:ok, path} = Briefly.create()

Then you can write to the path and read the contents of the file:

File.write!(path, "My temp file contents")!(path)
# => "My temp files contents"

When the requesting process exits, the file at path is removed.

Refer to the usage guide for more examples:

Run in Livebook



Am i correct in reading the code that it bases the directory name from the systems monotonic time ? I see the randomness added to that so its less predictable

Edit: I might spend some time auditing this, as it looks like it may have some other issues.


1 Like

Feel free to open issues/PRs! Briefly has been around for several years but has been lacking a recent release, so there is likely room still for improvement :slight_smile: