From 6ff9e35043d46e655cb532032f4a77a9cd4a3d14 Mon Sep 17 00:00:00 2001 From: Ray Zane Date: Tue, 24 Nov 2020 18:43:55 -0500 Subject: [PATCH] Update documentation --- README.md | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f6c3ad9..1f67aa7 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,13 @@ iex> FileStore.delete(store, "bar") :ok ``` +Delete files in bulk: + +```elixir +iex> FileStore.delete_all(store, "profile/images/") +:ok +``` + ## Middleware #### Logger @@ -109,23 +116,40 @@ iex> FileStore.delete(store, "bar") To enable logging, just wrap your store with the logging middleware: ```elixir -FileStore.Adapters.Disk.new([...]) -|> FileStore.Middleware.Logger.new(store) -|> FileStore.read("test.txt") +iex> store +...> |> FileStore.Middleware.Logger.new(store) +...> |> FileStore.read("test.txt") # 02:37:30.724 [debug] READ OK key="test.txt" {:ok, "hello"} ``` #### Errors +The errors middleware will wrap error values: + +```elixir +iex> store +...> |> FileStore.Middleware.Errors.new() +...> |> FileStore.read("bizcorp.jpg") +{:error, %FileStore.Error{...}} +``` + +One of the following structs will be returned: + +- `FileStore.Error` +- `FileStore.UploadError` +- `FileStore.DownloadError` + +Because the error implements the `Exception` behaviour, you can `raise` it. + #### Prefix -The prefix adapter allows you to prepend a prefix to all operations. +The prefix middleware allows you to prepend a prefix to all operations. ```elixir -FileStore.Adapters.Disk.new([...]) -|> FileStore.Middleware.Prefix.new(prefix: "company/logos") -|> FileStore.read(store, "bizcorp.jpg") +iex> store +...> |> FileStore.Middleware.Prefix.new(prefix: "company/logos") +...> |> FileStore.read("bizcorp.jpg") ``` In the example above, `bizcorp.jpg` was translated to `companies/logos/bizcorp.jpg`.