Client for the YourImageShare upload API
(https://yourimageshare.com/about/api). Mirrors the existing JS, Python,
PHP, Go, Rust, and Ruby SDKs - same method names, same result shapes,
same error type - just idiomatic Elixir on top ({:ok, result} | {:error, %YourImageShare.APIError{}} tagged tuples, the direct
equivalent of Go's (result, error) return; bang variants that raise
are also provided).
Built on Req (https://hex.pm/packages/req) for HTTP + native
streaming multipart support.
Summary
Functions
Removes one of your uploads by id. Returns {:error, %APIError{}} on a 404/401.
Same as delete/2, but raises instead of returning {:error, _}.
Returns your uploads, newest first, 50 per page. opts[:page] < 2 fetches the first page.
Same as list/2, but raises instead of returning {:error, _}.
Builds a client. api_key is required - get one from the API tab at
https://yourimageshare.com/my-account.
Uploads a local file by path. Streams from disk via File.stream!/1 -
doesn't buffer the whole file in memory. opts[:expires_in] auto-deletes
the upload after that many seconds (60 to 2,592,000 = 30 days).
Same as upload/3, but raises YourImageShare.APIError instead of returning {:error, _}.
Uploads from any Enumerable/File.Stream (an open file, a network
stream, an in-memory list of binaries) - useful when the data isn't
already a file on disk. filename should include a real extension so
the server can infer the content type correctly.
Same as upload_stream/4, but raises instead of returning {:error, _}.
Types
Functions
@spec delete(t(), String.t()) :: :ok | {:error, YourImageShare.APIError.t()}
Removes one of your uploads by id. Returns {:error, %APIError{}} on a 404/401.
Same as delete/2, but raises instead of returning {:error, _}.
@spec list( t(), keyword() ) :: {:ok, YourImageShare.ListResult.t()} | {:error, YourImageShare.APIError.t()}
Returns your uploads, newest first, 50 per page. opts[:page] < 2 fetches the first page.
@spec list!( t(), keyword() ) :: YourImageShare.ListResult.t()
Same as list/2, but raises instead of returning {:error, _}.
Builds a client. api_key is required - get one from the API tab at
https://yourimageshare.com/my-account.
Options:
:base_url- overrides the API base URL (mainly for testing).:req_options- extra options merged into everyReq.new/1call, e.g.receive_timeout:or a custom:finchpool.
@spec upload(t(), Path.t(), keyword()) :: {:ok, YourImageShare.UploadResult.t()} | {:error, YourImageShare.APIError.t()}
Uploads a local file by path. Streams from disk via File.stream!/1 -
doesn't buffer the whole file in memory. opts[:expires_in] auto-deletes
the upload after that many seconds (60 to 2,592,000 = 30 days).
@spec upload!(t(), Path.t(), keyword()) :: YourImageShare.UploadResult.t()
Same as upload/3, but raises YourImageShare.APIError instead of returning {:error, _}.
@spec upload_stream(t(), Enumerable.t(), String.t(), keyword()) :: {:ok, YourImageShare.UploadResult.t()} | {:error, YourImageShare.APIError.t()}
Uploads from any Enumerable/File.Stream (an open file, a network
stream, an in-memory list of binaries) - useful when the data isn't
already a file on disk. filename should include a real extension so
the server can infer the content type correctly.
@spec upload_stream!(t(), Enumerable.t(), String.t(), keyword()) :: YourImageShare.UploadResult.t()
Same as upload_stream/4, but raises instead of returning {:error, _}.