GithubHelp home page GithubHelp logo

file_storage_api's Introduction

elixir workflow Hex.pm Hex Docs

FileStorageApi

Library to be able to upload and manage files to different storage service azure/s3

Installation

It can be added to your project by adding

def deps do
  [
    {:file_storage_api, "~> 1.0"}
  ]
end

Configuration

Ability to set storage engine currently S3 and Azure supported. For tests Mock can be used with the mox library.

config :file_storage_api, :storage_api, engine: Azure

S3 configuration (options from ex_aws_s3 library)

config :file_storage_api, :s3_config,
  host: "127.0.0.1",
  scheme: "http://",
  port: 9000,
  access_key_id: "admin",
  secret_access_key: "password",
  path_style: true

For test S3 can also be mocked by

config :file_storage_api, :s3_config, module: AwsMock

Azure configuration (options from azure library)

config :file_storage_api, :azure_blob,
  account_key: "password",
  account_name: "user",
  environment_suffix: "core.windows.net",
  host: ,
  development: "true" || "false"

It will need the package file in linux to be able to read mime types and work.

Dynamic configuration

You can use a map or keyword list to pass a long dynamic configuration in the connection field.

For azure

%{
  engine: :azure,
  config: %{
    host: "postfix.example",
    secret_key: "YWNjb3VudF9rZXk=",
    access_key: "amazing"
  }
}

For S3

%{
  engine: :s3,
  config: %{host: "test.example", secret_key: "test123", access_key: "amazing", scheme: "http://"}
}

For mocking you can set the engine to Mock

Multiple storage accounts

It can be necessary to connect to multiple S3- or Azure-accounts. This can be done by adding multiple connections, each with its own engine. To facilitate testing, it is possible to change the engine per connection.

โš ๏ธ A connection-name must end with _conn.


Example

Make a custom-connection, with a S3-engine in development, and a Azure-engine in production.

File: config/dev.exs:

config :file_storage_api, :custom_conn, engine: :s3

config :file_storage_api, :custom_s3_config,
  host: "127.0.0.1",
  scheme: "http://",
  port: 9000,
  access_key_id: "custom-admin",
  secret_access_key: "custom-password",
  path_style: true

File: config/prod.exs:

config :file_storage_api, :custom_conn, engine: :azure

config :file_storage_api, :custom_azure_blob,
  account_key: "custom-password",
  account_name: "custom-user",
  environment_suffix: "core.windows.net",
  host: ,
  development: "true" || "false"

file_storage_api's People

Contributors

bettyblocks-release-bot avatar nulian avatar archan937 avatar

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.