files

package
v0.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

README

File Storage Files SDK for API version 2018-11-09

This package allows you to interact with the Files File Storage API

Supported Authorizers

  • Azure Active Directory (for the Resource Endpoint https://storage.azure.com)
  • SharedKeyLite (Blob, File & Queue)

Example Usage

package main

import (
	"context"
	"fmt"
	"time"
	
	"github.com/Azure/go-autorest/autorest"
	"github.com/tombuildsstuff/giovanni/storage/2018-11-09/file/files"
)

func Example() error {
	accountName := "storageaccount1"
    storageAccountKey := "ABC123...."
    shareName := "myshare"
    directoryName := "myfiles"
    fileName := "example.txt"
    
    storageAuth := autorest.NewSharedKeyLiteAuthorizer(accountName, storageAccountKey)
    filesClient := files.New()
    filesClient.Client.Authorizer = storageAuth
    
    ctx := context.TODO()
    input := files.CreateInput{}
    if _, err := filesClient.Create(ctx, accountName, shareName, directoryName, fileName, input); err != nil {
        return fmt.Errorf("Error creating File: %s", err)
    }
    
    return nil 
}

Documentation

Index

Constants

View Source
const APIVersion = "2018-11-09"

APIVersion is the version of the API used for all Storage API Operations

View Source
const DefaultCopyPollDuration = 15 * time.Second

Variables

This section is empty.

Functions

func UserAgent

func UserAgent() string

Types

type ClearByteRangeInput

type ClearByteRangeInput struct {
	StartBytes int64
	EndBytes   int64
}

type Client

type Client struct {
	autorest.Client
	BaseURI string
}

Client is the base client for File Storage Shares.

func New

func New() Client

New creates an instance of the Client client.

func NewWithEnvironment

func NewWithEnvironment(environment azure.Environment) Client

NewWithEnvironment creates an instance of the Client client.

func (Client) AbortCopy

func (client Client) AbortCopy(ctx context.Context, accountName, shareName, path, fileName, copyID string) (result autorest.Response, err error)

AbortCopy aborts a pending Copy File operation, and leaves a destination file with zero length and full metadata

func (Client) AbortCopyPreparer

func (client Client) AbortCopyPreparer(ctx context.Context, accountName, shareName, path, fileName, copyID string) (*http.Request, error)

AbortCopyPreparer prepares the AbortCopy request.

func (Client) AbortCopyResponder

func (client Client) AbortCopyResponder(resp *http.Response) (result autorest.Response, err error)

AbortCopyResponder handles the response to the AbortCopy request. The method always closes the http.Response Body.

func (Client) AbortCopySender

func (client Client) AbortCopySender(req *http.Request) (*http.Response, error)

AbortCopySender sends the AbortCopy request. The method will close the http.Response Body if it receives an error.

func (Client) ClearByteRange

func (client Client) ClearByteRange(ctx context.Context, accountName, shareName, path, fileName string, input ClearByteRangeInput) (result autorest.Response, err error)

ClearByteRange clears the specified Byte Range from within the specified File

func (Client) ClearByteRangePreparer

func (client Client) ClearByteRangePreparer(ctx context.Context, accountName, shareName, path, fileName string, input ClearByteRangeInput) (*http.Request, error)

ClearByteRangePreparer prepares the ClearByteRange request.

func (Client) ClearByteRangeResponder

func (client Client) ClearByteRangeResponder(resp *http.Response) (result autorest.Response, err error)

ClearByteRangeResponder handles the response to the ClearByteRange request. The method always closes the http.Response Body.

func (Client) ClearByteRangeSender

func (client Client) ClearByteRangeSender(req *http.Request) (*http.Response, error)

ClearByteRangeSender sends the ClearByteRange request. The method will close the http.Response Body if it receives an error.

func (Client) Copy

func (client Client) Copy(ctx context.Context, accountName, shareName, path, fileName string, input CopyInput) (result CopyResult, err error)

Copy copies a blob or file to a destination file within the storage account asynchronously.

func (Client) CopyAndWait

func (client Client) CopyAndWait(ctx context.Context, accountName, shareName, path, fileName string, input CopyInput, pollDuration time.Duration) (result CopyResult, err error)

CopyAndWait is a convenience method which doesn't exist in the API, which copies the file and then waits for the copy to complete

func (Client) CopyPreparer

func (client Client) CopyPreparer(ctx context.Context, accountName, shareName, path, fileName string, input CopyInput) (*http.Request, error)

CopyPreparer prepares the Copy request.

func (Client) CopyResponder

func (client Client) CopyResponder(resp *http.Response) (result CopyResult, err error)

CopyResponder handles the response to the Copy request. The method always closes the http.Response Body.

func (Client) CopySender

func (client Client) CopySender(req *http.Request) (*http.Response, error)

CopySender sends the Copy request. The method will close the http.Response Body if it receives an error.

func (Client) Create

func (client Client) Create(ctx context.Context, accountName, shareName, path, fileName string, input CreateInput) (result autorest.Response, err error)

Create creates a new file or replaces a file.

func (Client) CreatePreparer

func (client Client) CreatePreparer(ctx context.Context, accountName, shareName, path, fileName string, input CreateInput) (*http.Request, error)

CreatePreparer prepares the Create request.

func (Client) CreateResponder

func (client Client) CreateResponder(resp *http.Response) (result autorest.Response, err error)

CreateResponder handles the response to the Create request. The method always closes the http.Response Body.

func (Client) CreateSender

func (client Client) CreateSender(req *http.Request) (*http.Response, error)

CreateSender sends the Create request. The method will close the http.Response Body if it receives an error.

func (Client) Delete

func (client Client) Delete(ctx context.Context, accountName, shareName, path, fileName string) (result autorest.Response, err error)

Delete immediately deletes the file from the File Share.

func (Client) DeletePreparer

func (client Client) DeletePreparer(ctx context.Context, accountName, shareName, path, fileName string) (*http.Request, error)

DeletePreparer prepares the Delete request.

func (Client) DeleteResponder

func (client Client) DeleteResponder(resp *http.Response) (result autorest.Response, err error)

DeleteResponder handles the response to the Delete request. The method always closes the http.Response Body.

func (Client) DeleteSender

func (client Client) DeleteSender(req *http.Request) (*http.Response, error)

DeleteSender sends the Delete request. The method will close the http.Response Body if it receives an error.

func (Client) GetByteRange

func (client Client) GetByteRange(ctx context.Context, accountName, shareName, path, fileName string, input GetByteRangeInput) (result GetByteRangeResult, err error)

GetByteRange returns the specified Byte Range from the specified File.

func (Client) GetByteRangePreparer

func (client Client) GetByteRangePreparer(ctx context.Context, accountName, shareName, path, fileName string, input GetByteRangeInput) (*http.Request, error)

GetByteRangePreparer prepares the GetByteRange request.

func (Client) GetByteRangeResponder

func (client Client) GetByteRangeResponder(resp *http.Response, length int64) (result GetByteRangeResult, err error)

GetByteRangeResponder handles the response to the GetByteRange request. The method always closes the http.Response Body.

func (Client) GetByteRangeSender

func (client Client) GetByteRangeSender(req *http.Request) (*http.Response, error)

GetByteRangeSender sends the GetByteRange request. The method will close the http.Response Body if it receives an error.

func (Client) GetFile

func (client Client) GetFile(ctx context.Context, accountName, shareName, path, fileName string, parallelism int) (result autorest.Response, outputBytes []byte, err error)

GetFile is a helper method to download a file by chunking it automatically

func (Client) GetMetaData

func (client Client) GetMetaData(ctx context.Context, accountName, shareName, path, fileName string) (result GetMetaDataResult, err error)

GetMetaData returns the MetaData for the specified File.

func (Client) GetMetaDataPreparer

func (client Client) GetMetaDataPreparer(ctx context.Context, accountName, shareName, path, fileName string) (*http.Request, error)

GetMetaDataPreparer prepares the GetMetaData request.

func (Client) GetMetaDataResponder

func (client Client) GetMetaDataResponder(resp *http.Response) (result GetMetaDataResult, err error)

GetMetaDataResponder handles the response to the GetMetaData request. The method always closes the http.Response Body.

func (Client) GetMetaDataSender

func (client Client) GetMetaDataSender(req *http.Request) (*http.Response, error)

GetMetaDataSender sends the GetMetaData request. The method will close the http.Response Body if it receives an error.

func (Client) GetProperties

func (client Client) GetProperties(ctx context.Context, accountName, shareName, path, fileName string) (result GetResult, err error)

GetProperties returns the Properties for the specified file

func (Client) GetPropertiesPreparer

func (client Client) GetPropertiesPreparer(ctx context.Context, accountName, shareName, path, fileName string) (*http.Request, error)

GetPropertiesPreparer prepares the GetProperties request.

func (Client) GetPropertiesResponder

func (client Client) GetPropertiesResponder(resp *http.Response) (result GetResult, err error)

GetPropertiesResponder handles the response to the GetProperties request. The method always closes the http.Response Body.

func (Client) GetPropertiesSender

func (client Client) GetPropertiesSender(req *http.Request) (*http.Response, error)

GetPropertiesSender sends the GetProperties request. The method will close the http.Response Body if it receives an error.

func (Client) GetResourceID

func (client Client) GetResourceID(accountName, shareName, directoryName, filePath string) string

GetResourceID returns the Resource ID for the given File This can be useful when, for example, you're using this as a unique identifier

func (Client) ListRanges

func (client Client) ListRanges(ctx context.Context, accountName, shareName, path, fileName string) (result ListRangesResult, err error)

ListRanges returns the list of valid ranges for the specified File.

func (Client) ListRangesPreparer

func (client Client) ListRangesPreparer(ctx context.Context, accountName, shareName, path, fileName string) (*http.Request, error)

ListRangesPreparer prepares the ListRanges request.

func (Client) ListRangesResponder

func (client Client) ListRangesResponder(resp *http.Response) (result ListRangesResult, err error)

ListRangesResponder handles the response to the ListRanges request. The method always closes the http.Response Body.

func (Client) ListRangesSender

func (client Client) ListRangesSender(req *http.Request) (*http.Response, error)

ListRangesSender sends the ListRanges request. The method will close the http.Response Body if it receives an error.

func (Client) PutByteRange

func (client Client) PutByteRange(ctx context.Context, accountName, shareName, path, fileName string, input PutByteRangeInput) (result autorest.Response, err error)

PutByteRange puts the specified Byte Range in the specified File.

func (Client) PutByteRangePreparer

func (client Client) PutByteRangePreparer(ctx context.Context, accountName, shareName, path, fileName string, input PutByteRangeInput) (*http.Request, error)

PutByteRangePreparer prepares the PutByteRange request.

func (Client) PutByteRangeResponder

func (client Client) PutByteRangeResponder(resp *http.Response) (result autorest.Response, err error)

PutByteRangeResponder handles the response to the PutByteRange request. The method always closes the http.Response Body.

func (Client) PutByteRangeSender

func (client Client) PutByteRangeSender(req *http.Request) (*http.Response, error)

PutByteRangeSender sends the PutByteRange request. The method will close the http.Response Body if it receives an error.

func (Client) PutFile

func (client Client) PutFile(ctx context.Context, accountName, shareName, path, fileName string, file *os.File, parallelism int) error

PutFile is a helper method which takes a file, and automatically chunks it up, rather than having to do this yourself

func (Client) SetMetaData

func (client Client) SetMetaData(ctx context.Context, accountName, shareName, path, fileName string, metaData map[string]string) (result autorest.Response, err error)

SetMetaData updates the specified File to have the specified MetaData.

func (Client) SetMetaDataPreparer

func (client Client) SetMetaDataPreparer(ctx context.Context, accountName, shareName, path, fileName string, metaData map[string]string) (*http.Request, error)

SetMetaDataPreparer prepares the SetMetaData request.

func (Client) SetMetaDataResponder

func (client Client) SetMetaDataResponder(resp *http.Response) (result autorest.Response, err error)

SetMetaDataResponder handles the response to the SetMetaData request. The method always closes the http.Response Body.

func (Client) SetMetaDataSender

func (client Client) SetMetaDataSender(req *http.Request) (*http.Response, error)

SetMetaDataSender sends the SetMetaData request. The method will close the http.Response Body if it receives an error.

func (Client) SetProperties

func (client Client) SetProperties(ctx context.Context, accountName, shareName, path, fileName string, input SetPropertiesInput) (result autorest.Response, err error)

SetProperties sets the specified properties on the specified File

func (Client) SetPropertiesPreparer

func (client Client) SetPropertiesPreparer(ctx context.Context, accountName, shareName, path, fileName string, input SetPropertiesInput) (*http.Request, error)

SetPropertiesPreparer prepares the SetProperties request.

func (Client) SetPropertiesResponder

func (client Client) SetPropertiesResponder(resp *http.Response) (result autorest.Response, err error)

SetPropertiesResponder handles the response to the SetProperties request. The method always closes the http.Response Body.

func (Client) SetPropertiesSender

func (client Client) SetPropertiesSender(req *http.Request) (*http.Response, error)

SetPropertiesSender sends the SetProperties request. The method will close the http.Response Body if it receives an error.

type CopyAndWaitResult

type CopyAndWaitResult struct {
	autorest.Response

	CopyID string
}

type CopyInput

type CopyInput struct {
	// Specifies the URL of the source file or blob, up to 2 KB in length.
	//
	// To copy a file to another file within the same storage account, you may use Shared Key to authenticate
	// the source file. If you are copying a file from another storage account, or if you are copying a blob from
	// the same storage account or another storage account, then you must authenticate the source file or blob using a
	// shared access signature. If the source is a public blob, no authentication is required to perform the copy
	// operation. A file in a share snapshot can also be specified as a copy source.
	CopySource string

	MetaData map[string]string
}

type CopyResult

type CopyResult struct {
	autorest.Response

	// The CopyID, which can be passed to AbortCopy to abort the copy.
	CopyID string

	// Either `success` or `pending`
	CopySuccess string
}

type CreateInput

type CreateInput struct {
	// This header specifies the maximum size for the file, up to 1 TiB.
	ContentLength int64

	// The MIME content type of the file
	// If not specified, the default type is application/octet-stream.
	ContentType *string

	// Specifies which content encodings have been applied to the file.
	// This value is returned to the client when the Get File operation is performed
	// on the file resource and can be used to decode file content.
	ContentEncoding *string

	// Specifies the natural languages used by this resource.
	ContentLanguage *string

	// The File service stores this value but does not use or modify it.
	CacheControl *string

	// Sets the file's MD5 hash.
	ContentMD5 *string

	// Sets the file’s Content-Disposition header.
	ContentDisposition *string

	MetaData map[string]string
}

type GetByteRangeInput

type GetByteRangeInput struct {
	StartBytes int64
	EndBytes   int64
}

type GetByteRangeResult

type GetByteRangeResult struct {
	autorest.Response

	Contents []byte
}

type GetMetaDataResult

type GetMetaDataResult struct {
	autorest.Response

	MetaData map[string]string
}

type GetResult

type GetResult struct {
	autorest.Response

	CacheControl          string
	ContentDisposition    string
	ContentEncoding       string
	ContentLanguage       string
	ContentLength         *int64
	ContentMD5            string
	ContentType           string
	CopyID                string
	CopyStatus            string
	CopySource            string
	CopyProgress          string
	CopyStatusDescription string
	CopyCompletionTime    string
	Encrypted             bool

	MetaData map[string]string
}

type ListRangesResult

type ListRangesResult struct {
	autorest.Response

	Ranges []Range `xml:"Range"`
}

type PutByteRangeInput

type PutByteRangeInput struct {
	StartBytes int64
	EndBytes   int64

	// Content is the File Contents for the specified range
	// which can be at most 4MB
	Content []byte
}

type Range

type Range struct {
	Start string `xml:"Start"`
	End   string `xml:"End"`
}

type ResourceID

type ResourceID struct {
	AccountName   string
	DirectoryName string
	FileName      string
	ShareName     string
}

func ParseResourceID added in v0.2.0

func ParseResourceID(id string) (*ResourceID, error)

ParseResourceID parses the specified Resource ID and returns an object which can be used to interact with Files within a Storage Share.

type SetPropertiesInput

type SetPropertiesInput struct {
	// Resizes a file to the specified size.
	// If the specified byte value is less than the current size of the file,
	// then all ranges above the specified byte value are cleared.
	ContentLength *int64

	// Modifies the cache control string for the file.
	// If this property is not specified on the request, then the property will be cleared for the file.
	// Subsequent calls to Get File Properties will not return this property,
	// unless it is explicitly set on the file again.
	ContentControl *string

	// Sets the file’s Content-Disposition header.
	// If this property is not specified on the request, then the property will be cleared for the file.
	// Subsequent calls to Get File Properties will not return this property,
	// unless it is explicitly set on the file again.
	ContentDisposition *string

	// Sets the file's content encoding.
	// If this property is not specified on the request, then the property will be cleared for the file.
	// Subsequent calls to Get File Properties will not return this property,
	// unless it is explicitly set on the file again.
	ContentEncoding *string

	// Sets the file's content language.
	// If this property is not specified on the request, then the property will be cleared for the file.
	// Subsequent calls to Get File Properties will not return this property,
	// unless it is explicitly set on the file again.
	ContentLanguage *string

	// Sets the file's MD5 hash.
	// If this property is not specified on the request, then the property will be cleared for the file.
	// Subsequent calls to Get File Properties will not return this property,
	// unless it is explicitly set on the file again.
	ContentMD5 *string

	// Sets the file's content type.
	// If this property is not specified on the request, then the property will be cleared for the file.
	// Subsequent calls to Get File Properties will not return this property,
	// unless it is explicitly set on the file again.
	ContentType *string
}

type StorageFile added in v0.11.0

type StorageFile interface {
	PutByteRange(ctx context.Context, accountName, shareName, path, fileName string, input PutByteRangeInput) (result autorest.Response, err error)
	GetByteRange(ctx context.Context, accountName, shareName, path, fileName string, input GetByteRangeInput) (result GetByteRangeResult, err error)
	ClearByteRange(ctx context.Context, accountName, shareName, path, fileName string, input ClearByteRangeInput) (result autorest.Response, err error)
	SetProperties(ctx context.Context, accountName, shareName, path, fileName string, input SetPropertiesInput) (result autorest.Response, err error)
	PutFile(ctx context.Context, accountName, shareName, path, fileName string, file *os.File, parallelism int) error
	Copy(ctx context.Context, accountName, shareName, path, fileName string, input CopyInput) (result CopyResult, err error)
	SetMetaData(ctx context.Context, accountName, shareName, path, fileName string, metaData map[string]string) (result autorest.Response, err error)
	GetMetaData(ctx context.Context, accountName, shareName, path, fileName string) (result GetMetaDataResult, err error)
	AbortCopy(ctx context.Context, accountName, shareName, path, fileName, copyID string) (result autorest.Response, err error)
	GetFile(ctx context.Context, accountName, shareName, path, fileName string, parallelism int) (result autorest.Response, outputBytes []byte, err error)
	GetResourceID(accountName, shareName, directoryName, filePath string) string
	ListRanges(ctx context.Context, accountName, shareName, path, fileName string) (result ListRangesResult, err error)
	GetProperties(ctx context.Context, accountName, shareName, path, fileName string) (result GetResult, err error)
	Delete(ctx context.Context, accountName, shareName, path, fileName string) (result autorest.Response, err error)
	Create(ctx context.Context, accountName, shareName, path, fileName string, input CreateInput) (result autorest.Response, err error)
	CopyAndWait(ctx context.Context, accountName, shareName, path, fileName string, input CopyInput, pollDuration time.Duration) (result CopyResult, err error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL