Packages
upstream
1.6.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/b2/upload/file.ex
defmodule Upstream.B2.Upload.File do
@moduledoc """
Upload Standard File
"""
defstruct [
:file_id,
:file_name,
:account_id,
:bucket_id,
:content_length,
:content_sha1,
:content_type,
:file_info,
:action,
:upload_timestamp
]
@type t :: %__MODULE__{
file_id: String.t(),
file_name: String.t(),
account_id: String.t(),
bucket_id: String.t(),
content_length: integer,
content_sha1: String.t(),
content_type: String.t(),
file_info: map,
action: String.t(),
upload_timestamp: integer
}
use Upstream.B2.Base
def url(upload_url) when is_binary(upload_url), do: upload_url
def header(file_data) do
metadata =
file_data
|> Map.get(:file_info, %{})
|> Enum.map(fn {key, val} -> {"X-Bz-Info-#{key}", val} end)
[
{"Authorization", file_data.authorization},
{"X-Bz-File-Name", file_data.file_name},
{"Content-Type", "b2/x-auto"},
{"Content-Length", file_data.content_length},
{"X-Bz-Content-Sha1", file_data.x_bz_content_sha1}
| metadata
]
end
def body(body), do: {:stream, body}
end