AzureStorage.Blob (AzureStorage v0.1.6) View Source
Azure Blob Service
Create Azure Blob Service Request Context before using any of the following methods.
{:ok, context} = AzureStorage.create_blob_service("account_name", "account_key")
context |> list_containers()
Link to this section Summary
Functions
Acquires a new lease. If container and blob are specified, acquires a blob lease. Otherwise, if only container is specified and blob is null, acquires a container lease.
The Create Container operation creates a new container under the specified account.
Delete blob witin blob container
The Delete Container operation marks the specified container for deletion.
The Get Blob operation reads or downloads a blob from the system, including its metadata and properties.
The Get Container Metadata operation returns all user-defined metadata for the container.
The Get Container Properties operation returns all user-defined metadata and system properties for the specified container. The data returned does not include the container's list of blobs.
Free acquired lease so other client may immediately acquire a lease against the blob.
The List Blobs operation returns a list of the blobs under the specified container.
The List Containers operation returns a list of the containers under the specified storage account.
Create new blob in a blob container
The Set Container Metadata operation sets one or more user-defined name-value pairs for the specified container.
Sharing blob file using Share Access Signature
Link to this section Functions
Acquires a new lease. If container and blob are specified, acquires a blob lease. Otherwise, if only container is specified and blob is null, acquires a container lease.
Supported options
:duration
- Specifies the duration of the lease, in seconds, or negative on(-1) for a lease that never expires. A non-inifinite lease can be between 15 and 60 seconds. The default value is15
.:propose_lease_id
- Proposed lease ID, in a GUID string format. The default value is""
.
Specs
create_container(AzureStorage.Request.Context.t(), String.t()) :: {:ok, String.t()} | {:error, String.t()}
The Create Container operation creates a new container under the specified account.
If the container with the same name already exists, the operation fails.
Delete blob witin blob container
Specs
delete_container(AzureStorage.Request.Context.t(), String.t()) :: {:ok, String.t()} | {:error, String.t()}
The Delete Container operation marks the specified container for deletion.
The container and any blobs contained within it are later deleted during garbage collection.
The Get Blob operation reads or downloads a blob from the system, including its metadata and properties.
Supported options
:lease_id
- Active lease id The default value is""
.:json
- Iftrue
return content is inmap()
The default value isfalse
.
# get plain/text content
{:ok, content, attributes} = context
|> get_blob_content("container1", "data.txt")
{:ok, "Hello World!", %{"Content-Type" => "plain/text", ...}}
# get json content
context |> get_blob_content("container1", "data.json", json: true)
{:ok, %{"data" => []}, %{"Content-Type" => "application/json", ...}}
The Get Container Metadata operation returns all user-defined metadata for the container.
The Get Container Properties operation returns all user-defined metadata and system properties for the specified container. The data returned does not include the container's list of blobs.
Free acquired lease so other client may immediately acquire a lease against the blob.
Specs
list_blobs(AzureStorage.Request.Context.t(), String.t(), keyword()) :: {:ok, %{items: list() | [], marker: String.t() | nil}} | {:error, String.t()}
The List Blobs operation returns a list of the blobs under the specified container.
Supported options:
:maxresults
- The default value is1
.:marker
- false The default value is""
.:prefix
- false:timeout
- false The default value is30
.
Specs
list_containers(AzureStorage.Request.Context.t(), keyword()) :: {:ok, %{items: list() | [], marker: String.t() | nil}} | {:error, String.t()}
The List Containers operation returns a list of the containers under the specified storage account.
Supported options:
:maxresults
- The default value is1
.:marker
- false The default value is""
.:prefix
- false:timeout
- false The default value is30
.
Create new blob in a blob container
Supported options
:content_type
- Content-Type The default value is"text/plain;charset=\"utf-8\""
.
{:ok, context} = AzureStorage.create_blob_service("account_name", "account_key")
context |> put_blob("blobs",
"cache-key-1.json",
"{\"data\": []}",
content_type: "application/json;charset=\"utf-8\""
)
The Set Container Metadata operation sets one or more user-defined name-value pairs for the specified container.