Alixir.OSS (alixir_oss v0.2.1) View Source

Alixir.OSS enables puting and deleting objects for Aliyun OSS.

Examples

  Alixir.OSS.put_object(args...)
  |> Alixir.request()

  Alixir.OSS.delete_objects(args...)
  |> Alixir.request()

See put_object/4 and delete_object/4 for more details.

Link to this section Summary

Functions

Delete object from OSS. Return an Alixir.OSS.Operation struct which could be passed to Alixir.request to perform the request.

Head an object. Return true if the object exists, or false if it doesn't exist.

Generate a presigned URL, which could be used by other other applications (such as frontend) to operate OSS

Generate a presigned URL, which could be used by other other applications (such as frontend) to operate OSS

Put object to OSS. Return an Alixir.OSS.Operation struct which could be passed to Alixir.request to perform the request.

Link to this section Functions

Link to this function

delete_object(file_object, oss_headers \\ [])

View Source

Specs

delete_object(
  %Alixir.OSS.FileObject{bucket: term(), object: term(), object_key: term()},
  list()
) :: %Alixir.OSS.Operation{
  bucket: term(),
  file: term(),
  http_method: :delete,
  object_key: term(),
  oss_headers: term()
}

Delete object from OSS. Return an Alixir.OSS.Operation struct which could be passed to Alixir.request to perform the request.

Example

iex> file_object = %Alixir.OSS.FileObject{bucket: "foo_bucket", object_key: "foo/bar.jpg"} ...> operation = Alixir.OSS.delete_object(file_object) ...> with %Alixir.OSS.Operation{http_method: :delete, bucket: "foo_bucket", object_key: "foo/bar.jpg", ...> oss_headers: oss_headers} when is_list(oss_headers) <- operation, do: true true

Link to this function

head_object(bucket, key)

View Source

Specs

head_object(String.t(), String.t()) :: boolean()

Head an object. Return true if the object exists, or false if it doesn't exist.

Link to this function

post_object_data(file_object, policy_options \\ [])

View Source

Specs

post_object_data(
  %Alixir.OSS.FileObject{bucket: term(), object: term(), object_key: term()},
  Keyword.t()
) :: map()

Generate a presigned URL, which could be used by other other applications (such as frontend) to operate OSS

Link to this function

presigned_url(http_method, file_object, options \\ [])

View Source

Specs

presigned_url(
  atom(),
  %Alixir.OSS.FileObject{bucket: term(), object: term(), object_key: term()},
  Keyword.t()
) :: String.t()

Generate a presigned URL, which could be used by other other applications (such as frontend) to operate OSS

Link to this function

put_object(file_object, oss_headers \\ [])

View Source

Specs

put_object(
  %Alixir.OSS.FileObject{bucket: term(), object: term(), object_key: term()},
  list()
) :: %Alixir.OSS.Operation{
  bucket: term(),
  file: term(),
  http_method: :put,
  object_key: term(),
  oss_headers: term()
}

Put object to OSS. Return an Alixir.OSS.Operation struct which could be passed to Alixir.request to perform the request.

Example

iex> file_object = %Alixir.OSS.FileObject{bucket: "foo_bucket", object_key: "foo/bar.jpg", object: File.stream!("test/data/bar.jpg")} ...> operation = Alixir.OSS.put_object(file_object, "X-OSS-Object-Acl": "public-read") ...> with %Alixir.OSS.Operation{http_method: :put, bucket: "foo_bucket", object_key: "foo/bar.jpg", ...> file: %File.Stream{path: "test/data/bar.jpg"}, oss_headers: oss_headers} when is_list(oss_headers) <- operation, do: true true