8000 GitHub - alexandrubagu/gcs_signed_url at v0.3.0
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

alexandrubagu/gcs_signed_url

Repository files navigation

gcs_signed_url - Create Signed URLs for Google Cloud Storage

Travis Hex.pm Hex.pm Hex.pm Coverage Status

Important

This package works with elixir >= 1.8 and otp >= 22.3

Hex Installation

Add gcs_signed_url to your list of dependencies in mix.exs:

def deps do
  [{:gcs_signed_url, "~> 0.3.0"}]
end

Usage V4 Signatures

We advise to use Goth to authenticate against your Google Storage API:

    iex> {:ok, private_key} = Goth.Config.get(:private_key)
    iex> {:ok, client_email} = Goth.Config.get(:client_email)

    %GcsSignedUrl.Client{private_key: private_key, client_email: client_email}
    |> GcsSignedUrl.generate_v4("my-bucket", "my-object.mp4", expires: 60*20, headers: ["Content-Type": "image/jpeg"])

Usage Old V2 signatures

  1. Load the client
iex> GcsSignedUrl.Client.load_from_file("/home/alexandrubagu/config/google.json")

or

iex> service_account = service_account_json_string |> Jason.decode!
iex> GcsSignedUrl.Client.load(service_account)
  1. Generate signed url
GcsSignedUrl.generate(client, "my-bucket", "my-object.mp4")
GcsSignedUrl.generate(client, "my-bucket", "my-object.mp4", expires: GcsSignedUrl.hours_after(3))

Packages

No packages published

Contributors 9

Languages

0