Packages
upstream
2.1.0
2.1.4
2.1.3
2.1.2
2.1.1
2.1.0
2.0.7
2.0.6
2.0.5
2.0.4
2.0.3
2.0.2
2.0.0
1.8.2
1.8.1
1.7.2
1.7.1
1.7.0
1.6.14
1.6.13
1.6.12
1.6.11
1.6.10
1.6.9
1.6.8
1.6.7
1.6.6
1.6.5
1.6.4
1.6.3
1.6.2
1.6.1
1.6.0
1.5.12
1.5.11
1.5.11-dev-3
1.5.11-dev-2
1.5.11-dev-1
1.5.11-dev
1.5.10
1.5.9
1.5.8
1.5.7
1.5.6
1.5.5
1.5.2
1.5.1
1.5.0
1.4.12
1.4.9
1.4.6
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.7
1.3.5
1.3.4
1.3.3
1.3.2
1.3.1
1.3.0
1.2.3
1.2.1
Upstream is for integrating into projects that need to do large file uploads to B2 service. It integrates tightly with Backblaze B2 for now, with plans to support Amazon S3.
Current section
Files
Jump to
Current section
Files
lib/upstream.ex
defmodule Upstream do
@moduledoc """
Upstream is a utility for working with file upload.
It specifically integrates with backblaze b2 object store service.
"""
require Logger
@doc """
Upstream.base_api returns the base api string
## Examples
iex> Upstream.base_api
"https://api.backblazeb2.com"
"""
@b2_base_api ~S(https://api.backblazeb2.com)
def base_api, do: @b2_base_api
@spec config() :: any()
def config, do: Application.get_env(:upstream, Upstream) || []
@spec storage() :: any()
def storage, do: Application.get_env(:upstream, :storage) || []
@file_param "file"
@spec file_param() :: any()
def file_param, do: config(:file_param) || @file_param
@spec config(atom()) :: any()
def config(key), do: Keyword.get(config(), key, nil)
@spec storage(atom()) :: any()
def storage(key), do: Keyword.get(storage(), key, nil)
@spec reboot() :: {:error, {atom(), any()}} | {:ok, [atom()]}
def reboot do
Application.stop(:upstream)
Application.ensure_all_started(:upstream)
end
@spec reset() :: {:error, {atom(), any()}} | {:ok, [atom()]}
def reset do
Logger.info("[Upstream] -----> Flushing config and restarting")
Application.delete_env(:upstream, :storage)
reboot()
end
@spec set_config(any()) :: {:error, {atom(), any()}} | {:ok, [atom()]}
def set_config(config) do
Logger.info("[Upstream] -----> Setting config and restarting")
Application.put_env(:upstream, :storage, config)
reboot()
end
end