GithubHelp home page GithubHelp logo

sneako / briefly Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cargosense/briefly

0.0 2.0 0.0 36 KB

Simple, robust temporary file support for Elixir.

Home Page: http://hexdocs.pm/briefly

License: Other

Elixir 100.00%

briefly's Introduction

Briefly

Build Status

Simple, robust temporary file support for Elixir.

Highlighted Features

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

Installation

Add as a dependency to your mix.exs:

def deps do
  [
    briefly: "~> 0.4"
  ]
end

Install it with mix deps.get.

Example

Create a file:

{:ok, path} = Briefly.create
File.write!(path, "Some Text")
content = File.read!(path)
# When this process exits, the file at `path` is removed

Create a directory:

{:ok, path} = Briefly.create(directory: true)
File.write!(Path.join(path, "test.txt"), "Some Text")
# When this process exits, the directory and file are removed

See the documentation to see the options that available to Briefly.create/1 and Briefly.create!/1.

Configuration

The default, out-of-the-box settings for Briefly are equivalent to the following Mix config:

config :briefly,
  directory: [{:system, "TMPDIR"}, {:system, "TMP"}, {:system, "TEMP"}, "/tmp"],
  default_prefix: "briefly",
  default_extname: ""

directory here declares an ordered list of possible directory definitions that Briefly will check in order.

The {:system, env_var} tuples point to system environment variables to be checked. If none of these are defined, Briefly will use the final entry: /tmp.

You can override the settings with your own candidates in your application Mix config (and pass prefix and extname to Briefly.create to override default_prefix and default_extname on a case-by-case basis).

License

See LICENSE.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.