storage

package
v1.22.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidFormat = &Error{
	Code:    "InvalidFormat",
	Message: "invalid format",
	KV:      map[string]interface{}{},
}

ErrInvalidFormat is Format Error

View Source
var ErrParseFailure = errors.New("parse fail")

ErrParseFailure is Parse失敗時のError

Functions

func NewErrInvalidFormat added in v1.21.0

func NewErrInvalidFormat(message string, kv map[string]interface{}, err error) error

NewErrPermissionDenied is return ErrPermissionDenied

Types

type Attributes added in v1.2.0

type Attributes struct {
	BucketID                string                `json:"bucketId"`
	ObjectID                string                `json:"objectId"`
	ObjectGeneration        string                `json:"objectGeneration"`
	EventTime               time.Time             `json:"eventTime"`
	EventType               PubSubNotifyEventType `json:"eventType"`
	PayloadFormat           string                `json:"payloadFormat"`
	NotificationConfig      string                `json:"notificationConfig"`
	OverwrittenByGeneration int                   `json:"overwrittenByGeneration"`
	OverwroteGeneration     int                   `json:"overwroteGeneration"`
}

Attributes is PubSubからPushされたMessageのObjectの変更に関連する内容

type CreateDownloadSignedURLParam added in v1.19.0

type CreateDownloadSignedURLParam struct {
	// DownloadFileName is Download時のFileName
	// 指定しない場合はCloud Storageの最後の "/" 以降の Object Name
	// optional
	DownloadFileName string `json:"downloadFileName"`
	// Attachment is ファイルダウンロードを強制する
	Attachment bool `json:"isAttachment"`
	// Download時のContentTypeを指定する
	// 指定しない場合はCloud StorageのObjectのContent Type
	// optional
	DownloadContentType string `json:"downloadContentType"`
}

CreateDownloadSignedURLParam is param for create download signed url

type Error added in v1.21.0

type Error struct {
	Code    string
	Message string
	KV      map[string]interface{}
	// contains filtered or unexported fields
}

Error is Error情報を保持する struct

func (*Error) Error added in v1.21.0

func (e *Error) Error() string

Error is error interface func

func (*Error) Is added in v1.21.0

func (e *Error) Is(target error) bool

Is is err equal check

func (*Error) Unwrap added in v1.21.0

func (e *Error) Unwrap() error

Unwrap is return unwrap error

type Message added in v1.2.0

type Message struct {
	Data        MessageData `json:"data"`
	Attributes  Attributes  `json:"attributes"`
	MessageID   string      `json:"messageId"`
	PublishTime time.Time   `json:"publishTime"`
}

Message is PubSubからPushされたMessageの中で、Messageに関連すること

type MessageBody added in v1.2.0

type MessageBody struct {
	Message      Message `json:"message"`
	Subscription string  `json:"subscription"`
}

MessageBody is PubSubからPushされたMessageのBody

func ReadPubSubNotifyBody added in v1.2.0

func ReadPubSubNotifyBody(body io.Reader) (*MessageBody, error)

ReadPubSubNotifyBody is PubSubからPushされたリクエストのBodyを読み込む

type MessageData added in v1.2.0

type MessageData struct {
	Kind                    string           `json:"kind"`
	ID                      string           `json:"id"`
	SelfLink                string           `json:"selfLink"`
	Name                    string           `json:"name"`
	Bucket                  string           `json:"bucket"`
	Generation              int              `json:"generation"`
	Metageneration          int              `json:"metageneration"`
	ContentType             string           `json:"contentType"`
	TimeCreated             time.Time        `json:"timeCreated"`
	Updated                 time.Time        `json:"updated"`
	StorageClass            StorageClassType `json:"storageClass"`
	TimeStorageClassUpdated time.Time        `json:"timeStorageClassUpdated"`
	Size                    int64            `json:"size"`
	MD5Hash                 string           `json:"md5hash"`
	MediaLink               string           `json:"mediaLink"`
	CRC32C                  string           `json:"crc32c"`
	Etag                    string           `json:"etag"`
}

MessageData is PubSubからPushされたMessageのObjectに関連する内容

type PubSubNotifyEventType added in v1.2.0

type PubSubNotifyEventType int

PubSubNotifyEventType is Cloud Storage PubSub Notification EventType see https://cloud.google.com/storage/docs/pubsub-notifications#events

const (
	ObjectFinalize PubSubNotifyEventType = iota
	ObjectMetaDataUpdate
	ObjectDelete
	ObjectArchive
)

PubSubNotifyEventType

func ParseStorageNotifyEventType added in v1.2.0

func ParseStorageNotifyEventType(eventType string) (PubSubNotifyEventType, error)

ParseStorageNotifyEventType is 文字列から PubSubNotifyEventType へ変換する

func (PubSubNotifyEventType) String added in v1.2.0

func (i PubSubNotifyEventType) String() string

type StorageClassType added in v1.2.0

type StorageClassType int

StorageClassType is Cloud Storage Class Type see https://cloud.google.com/storage/docs/storage-classes#classes

const (
	MultiRegional StorageClassType = iota
	Regional
	Nearline
	Coldline
	Standard
	DurableReducedAvailability
)

StorageClassType

func ParseStorageClassType added in v1.2.0

func ParseStorageClassType(storageClassType string) (StorageClassType, error)

ParseStorageClassType is 文字列からStorageClassType へ変換する

func (StorageClassType) String added in v1.2.0

func (i StorageClassType) String() string

type StorageService

type StorageService struct {
	StorageClient *gcs.Client
}

StorageService is Storage Util Service

func NewStorageService

func NewStorageService(ctx context.Context, gcs *gcs.Client) (*StorageService, error)

NewStorageService is StorageServiceを生成する

type StorageSignedURLService added in v1.7.0

type StorageSignedURLService struct {
	ServiceAccountEmail  string
	IAMService           *iam.Service
	IAMCredentialsClient *credentials.IamCredentialsClient
}

StorageSignedURLService is Storage Signed URL Util Service

func NewStorageSignedURLService added in v1.7.0

func NewStorageSignedURLService(ctx context.Context, serviceAccountEmail string, iamService *iam.Service, iamCredentialsClient *credentials.IamCredentialsClient) (*StorageSignedURLService, error)

NewStorageSignedURLService is StorageServiceを生成する

利用するServiceAccountの roles/iam.serviceAccountTokenCreator https://cloud.google.com/iam/docs/service-accounts?hl=en#the_service_account_token_creator_role を持っている必要がある serviceAccountEmail is SignedURLを発行するServiceAccountEmail iamService is iamService iamCredentialsClient is iamCredentialsClient

func (*StorageSignedURLService) CreateDownloadURL added in v1.19.0

func (s *StorageSignedURLService) CreateDownloadURL(ctx context.Context, bucket string, object string, expires time.Time, param *CreateDownloadSignedURLParam) (string, error)

CreateDownloadURL

func (*StorageSignedURLService) CreatePutObjectURL added in v1.7.0

func (s *StorageSignedURLService) CreatePutObjectURL(ctx context.Context, bucket string, object string, contentType string, expires time.Time) (string, error)

CreateSignedURLForPutObject is ObjectをPutするSignedURLを発行する

contentLength is optional contentLengthを指定すると、HeaderにContent-Lengthが追加される

func (*StorageSignedURLService) CreateSignedURL added in v1.20.0

func (s *StorageSignedURLService) CreateSignedURL(ctx context.Context, bucket string, object string, method string, contentType string, headers []string, queryParameters url.Values, expires time.Time) (string, error)

CreateSignedURL is 便利そうなレイヤーを挟まず、まるっと全部指定してSigned URLを生成する

Jump to

Keyboard shortcuts

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