Documentation
¶
Index ¶
- Variables
- func NewErrInvalidFormat(message string, kv map[string]interface{}, err error) error
- type Attributes
- type CreateDownloadSignedURLParam
- type Error
- type Message
- type MessageBody
- type MessageData
- type PubSubNotifyEventType
- type StorageClassType
- type StorageService
- type StorageSignedURLService
- func (s *StorageSignedURLService) CreateDownloadURL(ctx context.Context, bucket string, object string, expires time.Time, ...) (string, error)
- func (s *StorageSignedURLService) CreatePutObjectURL(ctx context.Context, bucket string, object string, contentType string, ...) (string, error)
- func (s *StorageSignedURLService) CreateSignedURL(ctx context.Context, bucket string, object string, method string, ...) (string, error)
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidFormat = &Error{ Code: "InvalidFormat", Message: "invalid format", KV: map[string]interface{}{}, }
ErrInvalidFormat is Format Error
var ErrParseFailure = errors.New("parse fail")
ErrParseFailure is Parse失敗時のError
Functions ¶
Types ¶
type Attributes ¶
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 ¶
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 ¶
type Error struct {
Code string
Message string
KV map[string]interface{}
// contains filtered or unexported fields
}
Error is Error情報を保持する struct
type Message ¶
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 ¶
type MessageBody struct {
Message Message `json:"message"`
Subscription string `json:"subscription"`
}
MessageBody is PubSubからPushされたMessageのBody
func ReadPubSubNotifyBody ¶
func ReadPubSubNotifyBody(body io.Reader) (*MessageBody, error)
ReadPubSubNotifyBody is PubSubからPushされたリクエストのBodyを読み込む
type MessageData ¶
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 ¶
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 ¶
func ParseStorageNotifyEventType(eventType string) (PubSubNotifyEventType, error)
ParseStorageNotifyEventType is 文字列から PubSubNotifyEventType へ変換する
func (PubSubNotifyEventType) String ¶
func (i PubSubNotifyEventType) String() string
type StorageClassType ¶
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 ¶
func ParseStorageClassType(storageClassType string) (StorageClassType, error)
ParseStorageClassType is 文字列からStorageClassType へ変換する
func (StorageClassType) String ¶
func (i StorageClassType) String() string
type StorageService ¶
StorageService is Storage Util Service
func NewStorageService ¶
NewStorageService is StorageServiceを生成する
type StorageSignedURLService ¶
type StorageSignedURLService struct {
ServiceAccountEmail string
IAMService *iam.Service
IAMCredentialsClient *credentials.IamCredentialsClient
}
StorageSignedURLService is Storage Signed URL Util Service
func NewStorageSignedURLService ¶
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 ¶
func (s *StorageSignedURLService) CreateDownloadURL(ctx context.Context, bucket string, object string, expires time.Time, param *CreateDownloadSignedURLParam) (string, error)
CreateDownloadURL
func (*StorageSignedURLService) CreatePutObjectURL ¶
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 ¶
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を生成する