Documentation ¶
Index ¶
- Constants
- Variables
- type Blob
- type BlobListResponse
- type BlobProperties
- type BlobStorageClient
- func (b BlobStorageClient) BlobExists(container, name string) (bool, error)
- func (b BlobStorageClient) ContainerExists(name string) (bool, error)
- func (b BlobStorageClient) CopyBlob(container, name, sourceBlob string) error
- func (b BlobStorageClient) CreateBlockBlob(container, name string) error
- func (b BlobStorageClient) CreateContainer(name string, access ContainerAccessType) error
- func (b BlobStorageClient) CreateContainerIfNotExists(name string, access ContainerAccessType) (bool, error)
- func (b BlobStorageClient) DeleteBlob(container, name string) error
- func (b BlobStorageClient) DeleteBlobIfExists(container, name string) (bool, error)
- func (b BlobStorageClient) DeleteContainer(name string) error
- func (b BlobStorageClient) DeleteContainerIfExists(name string) (bool, error)
- func (b BlobStorageClient) GetBlob(container, name string) (io.ReadCloser, error)
- func (b BlobStorageClient) GetBlobProperties(container, name string) (*BlobProperties, error)
- func (b BlobStorageClient) GetBlobRange(container, name, bytesRange string) (io.ReadCloser, error)
- func (b BlobStorageClient) GetBlobSASURI(container, name string, expiry time.Time, permissions string) (string, error)
- func (b BlobStorageClient) GetBlobUrl(container, name string) string
- func (b BlobStorageClient) GetBlockList(container, name string, blockType BlockListType) (BlockListResponse, error)
- func (b BlobStorageClient) GetPageRanges(container, name string) (GetPageRangesResponse, error)
- func (b BlobStorageClient) ListBlobs(container string, params ListBlobsParameters) (BlobListResponse, error)
- func (b BlobStorageClient) ListContainers(params ListContainersParameters) (ContainerListResponse, error)
- func (b BlobStorageClient) PutBlock(container, name, blockId string, chunk []byte) error
- func (b BlobStorageClient) PutBlockBlob(container, name string, blob io.Reader) error
- func (b BlobStorageClient) PutBlockList(container, name string, blocks []Block) error
- func (b BlobStorageClient) PutBlockWithLength(container, name, blockId string, size uint64, blob io.Reader) error
- func (b BlobStorageClient) PutPage(container, name string, startByte, endByte int64, writeType PageWriteType, ...) error
- func (b BlobStorageClient) PutPageBlob(container, name string, size int64) error
- type BlobType
- type Block
- type BlockListResponse
- type BlockListType
- type BlockResponse
- type BlockStatus
- type Container
- type ContainerAccessType
- type ContainerListResponse
- type ContainerProperties
- type GetPageRangesResponse
- type ListBlobsParameters
- type ListContainersParameters
- type PageRange
- type PageWriteType
- type StorageClient
- type StorageServiceError
Constants ¶
const ( MaxBlobBlockSize = 4 * 1024 * 1024 MaxBlobPageSize = 4 * 1024 * 1024 )
const ( DefaultBaseUrl = "core.windows.net" DefaultApiVersion = "2014-02-14" )
Variables ¶
var ( ErrNotCreated = errors.New("storage: operation has returned a successful error code other than 201 Created.") ErrNotAccepted = errors.New("storage: operation has returned a successful error code other than 202 Accepted.") )
Functions ¶
This section is empty.
Types ¶
type Blob ¶
type Blob struct { Name string `xml:"Name"` Properties BlobProperties `xml:"Properties"` }
A Blob is an entry in BlobListResponse.
type BlobListResponse ¶
type BlobListResponse struct { XMLName xml.Name `xml:"EnumerationResults"` Xmlns string `xml:"xmlns,attr"` Prefix string `xml:"Prefix"` Marker string `xml:"Marker"` NextMarker string `xml:"NextMarker"` MaxResults int64 `xml:"MaxResults"` Blobs []Blob `xml:"Blobs>Blob"` }
BlobListResponse contains the response fields from ListBlobs call. https://msdn.microsoft.com/en-us/library/azure/dd135734.aspx
type BlobProperties ¶
type BlobProperties struct { LastModified string `xml:"Last-Modified"` Etag string `xml:"Etag"` ContentMD5 string `xml:"Content-MD5"` ContentLength int64 `xml:"Content-Length"` ContentType string `xml:"Content-Type"` ContentEncoding string `xml:"Content-Encoding"` BlobType BlobType `xml:"x-ms-blob-blob-type"` SequenceNumber int64 `xml:"x-ms-blob-sequence-number"` CopyId string `xml:"CopyId"` CopyStatus string `xml:"CopyStatus"` CopySource string `xml:"CopySource"` CopyProgress string `xml:"CopyProgress"` CopyCompletionTime string `xml:"CopyCompletionTime"` CopyStatusDescription string `xml:"CopyStatusDescription"` }
BlobProperties contains various properties of a blob returned in various endpoints like ListBlobs or GetBlobProperties.
type BlobStorageClient ¶
type BlobStorageClient struct {
// contains filtered or unexported fields
}
func (BlobStorageClient) BlobExists ¶
func (b BlobStorageClient) BlobExists(container, name string) (bool, error)
BlobExists returns true if a blob with given name exists on the specified container of the storage account.
func (BlobStorageClient) ContainerExists ¶
func (b BlobStorageClient) ContainerExists(name string) (bool, error)
ContainerExists returns true if a container with given name exists on the storage account, otherwise returns false.
func (BlobStorageClient) CopyBlob ¶
func (b BlobStorageClient) CopyBlob(container, name, sourceBlob string) error
CopyBlob starts a blob copy operation and waits for the operation to complete. sourceBlob parameter must be a canonical URL to the blob (can be obtained using GetBlobURL method.) There is no SLA on blob copy and therefore this helper method works faster on smaller files. See https://msdn.microsoft.com/en-us/library/azure/dd894037.aspx
func (BlobStorageClient) CreateBlockBlob ¶
func (b BlobStorageClient) CreateBlockBlob(container, name string) error
CreateBlockBlob initializes an empty block blob with no blocks. See https://msdn.microsoft.com/en-us/library/azure/dd179451.aspx
func (BlobStorageClient) CreateContainer ¶
func (b BlobStorageClient) CreateContainer(name string, access ContainerAccessType) error
CreateContainer creates a blob container within the storage account with given name and access level. See https://msdn.microsoft.com/en-us/library/azure/dd179468.aspx Returns error if container already exists.
func (BlobStorageClient) CreateContainerIfNotExists ¶
func (b BlobStorageClient) CreateContainerIfNotExists(name string, access ContainerAccessType) (bool, error)
CreateContainerIfNotExists creates a blob container if it does not exist. Returns true if container is newly created or false if container already exists.
func (BlobStorageClient) DeleteBlob ¶
func (b BlobStorageClient) DeleteBlob(container, name string) error
DeleteBlob deletes the given blob from the specified container. If the blob does not exists at the time of the Delete Blob operation, it returns error. See https://msdn.microsoft.com/en-us/library/azure/dd179413.aspx
func (BlobStorageClient) DeleteBlobIfExists ¶
func (b BlobStorageClient) DeleteBlobIfExists(container, name string) (bool, error)
DeleteBlobIfExists deletes the given blob from the specified container If the blob is deleted with this call, returns true. Otherwise returns false. See https://msdn.microsoft.com/en-us/library/azure/dd179413.aspx
func (BlobStorageClient) DeleteContainer ¶
func (b BlobStorageClient) DeleteContainer(name string) error
DeleteContainer deletes the container with given name on the storage account. See https://msdn.microsoft.com/en-us/library/azure/dd179408.aspx If the container does not exist returns error.
func (BlobStorageClient) DeleteContainerIfExists ¶
func (b BlobStorageClient) DeleteContainerIfExists(name string) (bool, error)
DeleteContainer deletes the container with given name on the storage account if it exists. See https://msdn.microsoft.com/en-us/library/azure/dd179408.aspx Returns true if container is deleted with this call, or false if the container did not exist at the time of the Delete Container operation.
func (BlobStorageClient) GetBlob ¶
func (b BlobStorageClient) GetBlob(container, name string) (io.ReadCloser, error)
GetBlob downloads a blob to a stream. See https://msdn.microsoft.com/en-us/library/azure/dd179440.aspx
func (BlobStorageClient) GetBlobProperties ¶
func (b BlobStorageClient) GetBlobProperties(container, name string) (*BlobProperties, error)
GetBlobProperties provides various information about the specified blob. See https://msdn.microsoft.com/en-us/library/azure/dd179394.aspx
func (BlobStorageClient) GetBlobRange ¶
func (b BlobStorageClient) GetBlobRange(container, name, bytesRange string) (io.ReadCloser, error)
GetBlobRange reads the specified range of a blob to a stream. The bytesRange string must be in a format like "0-", "10-100" as defined in HTTP 1.1 spec. See https://msdn.microsoft.com/en-us/library/azure/dd179440.aspx
func (BlobStorageClient) GetBlobSASURI ¶
func (b BlobStorageClient) GetBlobSASURI(container, name string, expiry time.Time, permissions string) (string, error)
GetBlobSASURI creates an URL to the specified blob which contains the Shared Access Signature with specified permissions and expiration time. See https://msdn.microsoft.com/en-us/library/azure/ee395415.aspx
func (BlobStorageClient) GetBlobUrl ¶
func (b BlobStorageClient) GetBlobUrl(container, name string) string
GetBlobUrl gets the canonical URL to the blob with the specified name in the specified container. This method does not create a publicly accessible URL if the blob or container is private and this method does not check if the blob exists.
func (BlobStorageClient) GetBlockList ¶
func (b BlobStorageClient) GetBlockList(container, name string, blockType BlockListType) (BlockListResponse, error)
GetBlockList retrieves list of blocks in the specified block blob. See https://msdn.microsoft.com/en-us/library/azure/dd179400.aspx
func (BlobStorageClient) GetPageRanges ¶
func (b BlobStorageClient) GetPageRanges(container, name string) (GetPageRangesResponse, error)
GetPageRanges returns the list of valid page ranges for a page blob. See https://msdn.microsoft.com/en-us/library/azure/ee691973.aspx
func (BlobStorageClient) ListBlobs ¶
func (b BlobStorageClient) ListBlobs(container string, params ListBlobsParameters) (BlobListResponse, error)
ListBlobs returns an object that contains list of blobs in the container, pagination token and other information in the response of List Blobs call. See https://msdn.microsoft.com/en-us/library/azure/dd135734.aspx
func (BlobStorageClient) ListContainers ¶
func (b BlobStorageClient) ListContainers(params ListContainersParameters) (ContainerListResponse, error)
ListContainers returns the list of containers in a storage account along with pagination token and other response details. See https://msdn.microsoft.com/en-us/library/azure/dd179352.aspx
func (BlobStorageClient) PutBlock ¶
func (b BlobStorageClient) PutBlock(container, name, blockId string, chunk []byte) error
PutBlock saves the given data chunk to the specified block blob with given ID. See https://msdn.microsoft.com/en-us/library/azure/dd135726.aspx
func (BlobStorageClient) PutBlockBlob ¶
func (b BlobStorageClient) PutBlockBlob(container, name string, blob io.Reader) error
PutBlockBlob uploads given stream into a block blob by splitting data stream into chunks and uploading as blocks. Commits the block list at the end. This is a helper method built on top of PutBlock and PutBlockList methods with sequential block ID counting logic.
func (BlobStorageClient) PutBlockList ¶
func (b BlobStorageClient) PutBlockList(container, name string, blocks []Block) error
PutBlockList saves list of blocks to the specified block blob. See https://msdn.microsoft.com/en-us/library/azure/dd179467.aspx
func (BlobStorageClient) PutBlockWithLength ¶
func (b BlobStorageClient) PutBlockWithLength(container, name, blockId string, size uint64, blob io.Reader) error
PutBlockWithLength saves the given data stream of exactly specified size to the block blob with given ID. See https://msdn.microsoft.com/en-us/library/azure/dd135726.aspx It is an alternative to PutBlocks where data comes as stream but the length is known in advance.
func (BlobStorageClient) PutPage ¶
func (b BlobStorageClient) PutPage(container, name string, startByte, endByte int64, writeType PageWriteType, chunk []byte) error
PutPage writes a range of pages to a page blob or clears the given range. In case of 'clear' writes, given chunk is discarded. Ranges must be aligned with 512-byte boundaries and chunk must be of size multiplies by 512. See https://msdn.microsoft.com/en-us/library/ee691975.aspx
func (BlobStorageClient) PutPageBlob ¶
func (b BlobStorageClient) PutPageBlob(container, name string, size int64) error
PutPageBlob initializes an empty page blob with specified name and maximum size in bytes (size must be aligned to a 512-byte boundary). A page blob must be created using this method before writing pages. See https://msdn.microsoft.com/en-us/library/azure/dd179451.aspx
type Block ¶
type Block struct { Id string Status BlockStatus }
Block is used to create Block entities for Put Block List call.
type BlockListResponse ¶
type BlockListResponse struct { XMLName xml.Name `xml:"BlockList"` CommittedBlocks []BlockResponse `xml:"CommittedBlocks>Block"` UncommittedBlocks []BlockResponse `xml:"UncommittedBlocks>Block"` }
BlockListResponse contains the response fields from Get Block List call. https://msdn.microsoft.com/en-us/library/azure/dd179400.aspx
type BlockListType ¶
type BlockListType string
BlockListType is used to filter out types of blocks in a Get Blocks List call for a block blob. See https://msdn.microsoft.com/en-us/library/azure/dd179400.aspx for all block types.
const ( BlockListTypeAll BlockListType = "all" BlockListTypeCommitted BlockListType = "committed" BlockListTypeUncommitted BlockListType = "uncommitted" )
type BlockResponse ¶
BlockResponse contains the block information returned in the GetBlockListCall.
type BlockStatus ¶
type BlockStatus string
BlockStatus defines states a block for a block blob can be in.
const ( BlockStatusUncommitted BlockStatus = "Uncommitted" BlockStatusCommitted BlockStatus = "Committed" BlockStatusLatest BlockStatus = "Latest" )
type Container ¶
type Container struct { Name string `xml:"Name"` Properties ContainerProperties `xml:"Properties"` }
A Container is an entry in ContainerListResponse.
type ContainerAccessType ¶
type ContainerAccessType string
ContainerAccessType defines the access level to the container from a public request. See https://msdn.microsoft.com/en-us/library/azure/dd179468.aspx and "x-ms-blob-public-access" header.
const ( ContainerAccessTypePrivate ContainerAccessType = "" ContainerAccessTypeBlob ContainerAccessType = "blob" ContainerAccessTypeContainer ContainerAccessType = "container" )
type ContainerListResponse ¶
type ContainerListResponse struct { XMLName xml.Name `xml:"EnumerationResults"` Xmlns string `xml:"xmlns,attr"` Prefix string `xml:"Prefix"` Marker string `xml:"Marker"` NextMarker string `xml:"NextMarker"` MaxResults int64 `xml:"MaxResults"` Containers []Container `xml:"Containers>Container"` }
ContainerListResponse contains the response fields from ListContainers call. https://msdn.microsoft.com/en-us/library/azure/dd179352.aspx
type ContainerProperties ¶
type ContainerProperties struct { LastModified string `xml:"Last-Modified"` Etag string `xml:"Etag"` LeaseStatus string `xml:"LeaseStatus"` LeaseState string `xml:"LeaseState"` LeaseDuration string `xml:"LeaseDuration"` }
ContainerProperties contains various properties of a container returned from various endpoints like ListContainers.
type GetPageRangesResponse ¶
type GetPageRangesResponse struct { XMLName xml.Name `xml:"PageList"` PageList []PageRange `xml:"PageRange"` }
GetPageRangesResponse contains the reponse fields from Get Page Ranges call. https://msdn.microsoft.com/en-us/library/azure/ee691973.aspx
type ListBlobsParameters ¶
type ListBlobsParameters struct { Prefix string Delimiter string Marker string Include string MaxResults uint Timeout uint }
ListBlobsParameters defines the set of customizable parameters to make a List Blobs call. https://msdn.microsoft.com/en-us/library/azure/dd135734.aspx
type ListContainersParameters ¶
type ListContainersParameters struct { Prefix string Marker string Include string MaxResults uint Timeout uint }
ListContainersParameters defines the set of customizable parameters to make a List Containers call. https://msdn.microsoft.com/en-us/library/azure/dd179352.aspx
type PageRange ¶
PageRange contains information about a page of a page blob from Get Pages Range call. https://msdn.microsoft.com/en-us/library/azure/ee691973.aspx
type PageWriteType ¶
type PageWriteType string
PageWriteType defines the type updates that are going to be done on the page blob.
const ( PageWriteTypeUpdate PageWriteType = "update" PageWriteTypeClear PageWriteType = "clear" )
type StorageClient ¶
type StorageClient struct {
// contains filtered or unexported fields
}
StorageClient is the object that needs to be constructed to perform operations on the storage account.
func NewBasicClient ¶
func NewBasicClient(accountName, accountKey string) (StorageClient, error)
NewBasicClient constructs a StorageClient with given storage service name and key.
func NewClient ¶
func NewClient(accountName, accountKey, blobServiceBaseUrl, apiVersion string, useHttps bool) (StorageClient, error)
NewClient constructs a StorageClient. This should be used if the caller wants to specify whether to use HTTPS, a specific REST API version or a custom storage endpoint than Azure Public Cloud.
func (StorageClient) GetBlobService ¶
func (c StorageClient) GetBlobService() *BlobStorageClient
GetBlobService returns a BlobStorageClient which can operate on the blob service of the storage account.
type StorageServiceError ¶
type StorageServiceError struct { Code string `xml:"Code"` Message string `xml:"Message"` AuthenticationErrorDetail string `xml:"AuthenticationErrorDetail"` QueryParameterName string `xml:"QueryParameterName"` QueryParameterValue string `xml:"QueryParameterValue"` Reason string `xml:"Reason"` StatusCode int RequestId string }
StorageServiceError contains fields of the error response from Azure Storage Service REST API. See https://msdn.microsoft.com/en-us/library/azure/dd179382.aspx Some fields might be specific to certain calls.
func (StorageServiceError) Error ¶
func (e StorageServiceError) Error() string