AzureStorage.FileShare (AzureStorage v0.1.6) View Source
Azure File Service
ref. https://docs.microsoft.com/en-us/rest/api/storageservices/file-service-rest-api
{:ok, context} = AzureStorage.create_fileshare_service("account_name", "account_key")
context |> list_shares()
Link to this section Summary
Functions
Create directory.
Creates a new file or replaces a file.
The Create Share operation creates a new share under the specified account. If the share with the same name already exists, the operation fails.
Delete empty directoy. Attempt to delete non-empty directory will return an {:error, reason}
The Delete File operation immediately removes the file from the storage account.
The Delete Share operation marks the specified share or share snapshot for deletion. The share or share snapshot and any files contained within it are later deleted during garbage collection.
Check if directories exist.
Reads or downloads a file from the system, including its metadata and properties.
The List Directories and Files operation returns a list of files or directories under the specified share or directory. It lists the contents only for a single level of the directory hierarchy.
The List Shares operation returns a list of the shares and share snapshots under the specified account.
Link to this section Functions
Create directory.
Creates a new file or replaces a file.
Delete empty directoy. Attempt to delete non-empty directory will return an {:error, reason}
Specs
delete_file(AzureStorage.Request.Context.t(), String.t(), String.t(), keyword()) :: {:ok, any()} | {:error, String.t()}
The Delete File operation immediately removes the file from the storage account.
Supported options
:lease_id
- If the file has an active lease
Specs
directory_exists(AzureStorage.Request.Context.t(), String.t(), String.t()) :: {:ok, String.t()} | {:error, String.t()}
Check if directories exist.
context |> AzureStorage.FileShare.directory_exists("testfileshare", "exist-dir")
{:ok, ""}
context |> AzureStorage.FileShare.directory_exists("testfileshare", "not-exist")
{:error, "ResourceNotFound"}
Specs
get_file(AzureStorage.Request.Context.t(), String.t(), String.t(), String.t()) :: {:ok, binary(), map()} | {:error, String.t()}
Reads or downloads a file from the system, including its metadata and properties.
context |> AzureStorage.FileShare.get_file("fileshare1", "directory1", "file1")
{:ok,
content,
%{
"Content-Type" => "application/json",
"Content-Length" => "20000",
"ETag" => "...",
"x-ms-version" => "...",
..
}
}
The List Directories and Files operation returns a list of files or directories under the specified share or directory. It lists the contents only for a single level of the directory hierarchy.
ref. https://docs.microsoft.com/en-us/rest/api/storageservices/list-directories-and-files
context |> AzureStorage.FileShare.list_directories("testfileshare", "parent-directory")
{:ok,
%{
directories: [%{"name" => "dir2"}],
files: [
%{"name" => "test.txt", "size" => 13},
%{"name" => "file1", "size" => 5242880}
],
marker: nil
}
}
Supported options:
:prefix
- false Filters the results to return only files and directories whose name begins with the specified prefix.:maxresults
- false Specifies the maximum number of files and/or directories to return. If the request does not specify maxresults or specifies a value greater than 5,000, the server will return up to 5,000 items. The default value is1000
.:marker
- false A string value that identifies the portion of the list to be returned with the next list operation. The operation returns a marker value within the response body if the list returned was not complete. The marker value may then be used in a subsequent call to request the next set of list items. The default value is""
.:timeout
- false The timeout parameter is expressed in seconds The default value is30
.