gcs v0.1.0 GCS View Source
A simple library to interact with Google Cloud Storage
Link to this section Summary
Link to this section Types
Link to this section Functions
delete_object(bucket, gcs_file_path, headers \\ [], http_opts \\ [])
View SourceDeletes a file from GCS
Requires the bucket name and the gcs file location with filename.
Examples
iex> File.write!("file.txt", "hello")
:ok
iex> GCS.upload_object("my-bucket", "myfile.txt", "file.txt", "Application/txt")
{:ok, %{...}} # GCS Response
iex> GCS.make_public("my-bucket", "myfile.txt")
{:ok, %{...}} # GCS Response
iex> SomeHTTPClient.get("https://storage.googleapis.com/my-bucket/myfile.txt")
{:ok, %{body: "hello"}}
download_object(bucket, gcs_file_path, headers \\ [], http_opts \\ [])
View SourceDownloads a file from GCS
Requires the bucket name and the gcs file location with filename.
Example: if the bucket is "my-bucket" and the gcs file path is "myfile.png", the file would be retrieved from "my-bucket" at the location "myfile.png".
More Examples
iex> File.write!("file.txt", "hello")
:ok
iex> GCS.upload_object("my-bucket", "myfile.txt", "file.txt", "Application/txt")
{:ok, %{...}} # GCS Response
iex> GCS.download_object("my-bucket", "myfile.txt")
"hello"
make_public(bucket, gcs_file_path, headers \\ [], http_opts \\ [])
View SourceMakes a file in GCS publicly accessible
Requires the bucket name and the gcs file location with filename.
The file will be available at https://storage.googleapis.com/bucket/file_path
Example: if the bucket is "my-bucket" and the gcs file path is "myfile.png", the url would be https://storage.googleapis.com/my-bucket/myfile.png.
More Examples
iex> File.write!("file.txt", "hello")
:ok
iex> GCS.upload_object("my-bucket", "myfile.txt", "file.txt", "Application/txt")
{:ok, %{...}} # GCS Response
iex> GCS.make_public("my-bucket", "myfile.txt")
{:ok, %{...}} # GCS Response
iex> SomeHTTPClient.get("https://storage.googleapis.com/my-bucket/myfile.txt")
{:ok, %{body: "hello"}}
upload_object(bucket, gcs_file_path, file_path, content_type, headers \\ [], http_opts \\ [])
View SourceUploads a file to GCS
Requires the bucket name, the desired gcs file location with desired filename, the path to the file to be uploaded, and the content type of the file.
Examples
iex> File.write!("file.txt", "hello")
:ok
iex> GCS.upload_object("my-bucket", "myfile.txt", "file.txt", "Application/txt")
{:ok, %{...}} # GCS Response