ExOss.LocalZipper (ExOss v1.0.0)

Copy Markdown View Source

Local zip generation for S3-compatible storage services that lack cloud-side zip capabilities.

This module downloads multiple files referenced by a zip index (produced by ExOss.Storage.mkzip_index_content/1), zips them in memory using :zip.zip/3, and returns the binary content. The resulting zip can then be uploaded to the storage backend via a ExOss.StorageTask.

Summary

Functions

Downloads all files referenced in the index and returns the zip binary.

Types

download_result()

@type download_result() :: {:ok, binary()} | :error

zip_entry()

@type zip_entry() :: {charlist(), binary()}

zip_list_result()

@type zip_list_result() :: {:ok, [zip_entry()]} | :error

Functions

zip(index_path)

@spec zip(binary()) :: {:ok, binary()} | {:error, :gen_file_error}

Downloads all files referenced in the index and returns the zip binary.

The index_path is the raw text returned by ExOss.Storage.mkzip_index_content/1. Each line encodes a URL and an alias name, both Base64 url-safe encoded:

/url/{base64(url)}/alias/{base64(alias_name)}

Examples

index = ExOss.Storage.mkzip_index_content([
  %{access_address: "https://s3.example.com/img1.jpg", alias_name: "img1.jpg"}
])

{:ok, zip_binary} = ExOss.LocalZipper.zip(index)

Returns {:ok, binary} on success, or {:error, :gen_file_error} on failure.