1### YamlMime:UniversalReference 2items: 3- uid: cloud.google.com/go/storage 4 name: cloud.google.com/go/storage 5 id: storage 6 summary: "Package storage provides an easy way to work with Google Cloud Storage.\nGoogle Cloud Storage stores data in named objects, which are grouped into buckets.\n\nMore information about Google Cloud Storage is available at\nhttps://cloud.google.com/storage/docs.\n\nSee https://godoc.org/cloud.google.com/go for authentication, timeouts,\nconnection pooling and similar aspects of this package.\n\nAll of the methods of this package use exponential backoff to retry calls that fail\nwith certain errors, as described in\nhttps://cloud.google.com/storage/docs/exponential-backoff. Retrying continues\nindefinitely unless the controlling context is canceled or the client is closed. See\ncontext.WithTimeout and context.WithCancel.\n\nCreating a Client\n\nTo start working with this package, create a client:\n\n ctx := context.Background()\n client, err := storage.NewClient(ctx)\n if err != nil {\n // TODO: Handle error.\n }\n\nThe client will use your default application credentials. Clients should be\nreused instead of created as needed. The methods of Client are safe for\nconcurrent use by multiple goroutines.\n\nIf you only wish to access public data, you can create\nan unauthenticated client with\n\n client, err := storage.NewClient(ctx, option.WithoutAuthentication())\n\nBuckets\n\nA Google Cloud Storage bucket is a collection of objects. To work with a\nbucket, make a bucket handle:\n\n bkt := client.Bucket(bucketName)\n\nA handle is a reference to a bucket. You can have a handle even if the\nbucket doesn't exist yet. To create a bucket in Google Cloud Storage,\ncall Create on the handle:\n\n if err := bkt.Create(ctx, projectID, nil); err != nil {\n // TODO: Handle error.\n }\n\nNote that although buckets are associated with projects, bucket names are\nglobal across all projects.\n\nEach bucket has associated metadata, represented in this package by\nBucketAttrs. The third argument to BucketHandle.Create allows you to set\nthe initial BucketAttrs of a bucket. To retrieve a bucket's attributes, use\nAttrs:\n\n attrs, err := bkt.Attrs(ctx)\n if err != nil {\n // TODO: Handle error.\n }\n fmt.Printf(\"bucket %s, created at %s, is located in %s with storage class %s\\n\",\n attrs.Name, attrs.Created, attrs.Location, attrs.StorageClass)\n\nObjects\n\nAn object holds arbitrary data as a sequence of bytes, like a file. You\nrefer to objects using a handle, just as with buckets, but unlike buckets\nyou don't explicitly create an object. Instead, the first time you write\nto an object it will be created. You can use the standard Go io.Reader\nand io.Writer interfaces to read and write object data:\n\n obj := bkt.Object(\"data\")\n // Write something to obj.\n // w implements io.Writer.\n w := obj.NewWriter(ctx)\n // Write some text to obj. This will either create the object or overwrite whatever is there already.\n if _, err := fmt.Fprintf(w, \"This object contains text.\\n\"); err != nil {\n // TODO: Handle error.\n }\n // Close, just like writing a file.\n if err := w.Close(); err != nil {\n // TODO: Handle error.\n }\n\n // Read it back.\n r, err := obj.NewReader(ctx)\n if err != nil {\n // TODO: Handle error.\n }\n defer r.Close()\n if _, err := io.Copy(os.Stdout, r); err != nil {\n // TODO: Handle error.\n }\n // Prints \"This object contains text.\"\n\nObjects also have attributes, which you can fetch with Attrs:\n\n objAttrs, err := obj.Attrs(ctx)\n if err != nil {\n // TODO: Handle error.\n }\n fmt.Printf(\"object %s has size %d and can be read using %s\\n\",\n objAttrs.Name, objAttrs.Size, objAttrs.MediaLink)\n\nListing objects\n\nListing objects in a bucket is done with the Bucket.Objects method:\n\n query := &storage.Query{Prefix: \"\"}\n\n var names []string\n it := bkt.Objects(ctx, query)\n for {\n attrs, err := it.Next()\n if err == iterator.Done {\n break\n }\n if err != nil {\n log.Fatal(err)\n }\n names = append(names, attrs.Name)\n }\n\nIf only a subset of object attributes is needed when listing, specifying this\nsubset using Query.SetAttrSelection may speed up the listing process:\n\n query := &storage.Query{Prefix: \"\"}\n query.SetAttrSelection([]string{\"Name\"})\n\n // ... as before\n\nACLs\n\nBoth objects and buckets have ACLs (Access Control Lists). An ACL is a list of\nACLRules, each of which specifies the role of a user, group or project. ACLs\nare suitable for fine-grained control, but you may prefer using IAM to control\naccess at the project level (see\nhttps://cloud.google.com/storage/docs/access-control/iam).\n\nTo list the ACLs of a bucket or object, obtain an ACLHandle and call its List method:\n\n acls, err := obj.ACL().List(ctx)\n if err != nil {\n // TODO: Handle error.\n }\n for _, rule := range acls {\n fmt.Printf(\"%s has role %s\\n\", rule.Entity, rule.Role)\n }\n\nYou can also set and delete ACLs.\n\nConditions\n\nEvery object has a generation and a metageneration. The generation changes\nwhenever the content changes, and the metageneration changes whenever the\nmetadata changes. Conditions let you check these values before an operation;\nthe operation only executes if the conditions match. You can use conditions to\nprevent race conditions in read-modify-write operations.\n\nFor example, say you've read an object's metadata into objAttrs. Now\nyou want to write to that object, but only if its contents haven't changed\nsince you read it. Here is how to express that:\n\n w = obj.If(storage.Conditions{GenerationMatch: objAttrs.Generation}).NewWriter(ctx)\n // Proceed with writing as above.\n\nSigned URLs\n\nYou can obtain a URL that lets anyone read or write an object for a limited time.\nYou don't need to create a client to do this. See the documentation of\nSignedURL for details.\n\n url, err := storage.SignedURL(bucketName, \"shared-object\", opts)\n if err != nil {\n // TODO: Handle error.\n }\n fmt.Println(url)\n\nPost Policy V4 Signed Request\n\nA type of signed request that allows uploads through HTML forms directly to Cloud Storage with\ntemporary permission. Conditions can be applied to restrict how the HTML form is used and exercised\nby a user.\n\nFor more information, please see https://cloud.google.com/storage/docs/xml-api/post-object as well\nas the documentation of GenerateSignedPostPolicyV4.\n\n pv4, err := storage.GenerateSignedPostPolicyV4(bucketName, objectName, opts)\n if err != nil {\n // TODO: Handle error.\n }\n fmt.Printf(\"URL: %s\\nFields; %v\\n\", pv4.URL, pv4.Fields)\n\nErrors\n\nErrors returned by this client are often of the type [`googleapi.Error`](https://godoc.org/google.golang.org/api/googleapi#Error).\nThese errors can be introspected for more information by type asserting to the richer `googleapi.Error` type. For example:\n\n\tif e, ok := err.(*googleapi.Error); ok {\n\t\t if e.Code == 409 { ... }\n\t}\n" 7 type: package 8 langs: 9 - go 10 children: 11 - cloud.google.com/go/storage.DeleteAction,SetStorageClassAction 12 - cloud.google.com/go/storage.NoPayload,JSONPayload 13 - cloud.google.com/go/storage.ObjectFinalizeEvent,ObjectMetadataUpdateEvent,ObjectDeleteEvent,ObjectArchiveEvent 14 - cloud.google.com/go/storage.ScopeFullControl,ScopeReadOnly,ScopeReadWrite 15 - cloud.google.com/go/storage.ErrBucketNotExist,ErrObjectNotExist 16 - cloud.google.com/go/storage.ACLEntity 17 - cloud.google.com/go/storage.AllUsers,AllAuthenticatedUsers 18 - cloud.google.com/go/storage.ACLHandle 19 - cloud.google.com/go/storage.ACLHandle.Delete 20 - cloud.google.com/go/storage.ACLHandle.List 21 - cloud.google.com/go/storage.ACLHandle.Set 22 - cloud.google.com/go/storage.ACLRole 23 - cloud.google.com/go/storage.RoleOwner,RoleReader,RoleWriter 24 - cloud.google.com/go/storage.ACLRule 25 - cloud.google.com/go/storage.BucketAttrs 26 - cloud.google.com/go/storage.BucketAttrsToUpdate 27 - cloud.google.com/go/storage.BucketAttrsToUpdate.DeleteLabel 28 - cloud.google.com/go/storage.BucketAttrsToUpdate.SetLabel 29 - cloud.google.com/go/storage.BucketConditions 30 - cloud.google.com/go/storage.BucketEncryption 31 - cloud.google.com/go/storage.BucketHandle 32 - cloud.google.com/go/storage.BucketHandle.ACL 33 - cloud.google.com/go/storage.BucketHandle.AddNotification 34 - cloud.google.com/go/storage.BucketHandle.Attrs 35 - cloud.google.com/go/storage.BucketHandle.Create 36 - cloud.google.com/go/storage.BucketHandle.DefaultObjectACL 37 - cloud.google.com/go/storage.BucketHandle.Delete 38 - cloud.google.com/go/storage.BucketHandle.DeleteNotification 39 - cloud.google.com/go/storage.BucketHandle.IAM 40 - cloud.google.com/go/storage.BucketHandle.If 41 - cloud.google.com/go/storage.BucketHandle.LockRetentionPolicy 42 - cloud.google.com/go/storage.BucketHandle.Notifications 43 - cloud.google.com/go/storage.BucketHandle.Object 44 - cloud.google.com/go/storage.BucketHandle.Objects 45 - cloud.google.com/go/storage.BucketHandle.Update 46 - cloud.google.com/go/storage.BucketHandle.UserProject 47 - cloud.google.com/go/storage.BucketIterator 48 - cloud.google.com/go/storage.BucketIterator.Next 49 - cloud.google.com/go/storage.BucketIterator.PageInfo 50 - cloud.google.com/go/storage.BucketLogging 51 - cloud.google.com/go/storage.BucketPolicyOnly 52 - cloud.google.com/go/storage.BucketWebsite 53 - cloud.google.com/go/storage.CORS 54 - cloud.google.com/go/storage.Client 55 - cloud.google.com/go/storage.Client.NewClient 56 - cloud.google.com/go/storage.Client.Bucket 57 - cloud.google.com/go/storage.Client.Buckets 58 - cloud.google.com/go/storage.Client.Close 59 - cloud.google.com/go/storage.Client.CreateHMACKey 60 - cloud.google.com/go/storage.Client.HMACKeyHandle 61 - cloud.google.com/go/storage.Client.ListHMACKeys 62 - cloud.google.com/go/storage.Client.ServiceAccount 63 - cloud.google.com/go/storage.Composer 64 - cloud.google.com/go/storage.Composer.Run 65 - cloud.google.com/go/storage.Conditions 66 - cloud.google.com/go/storage.Copier 67 - cloud.google.com/go/storage.Copier.Run 68 - cloud.google.com/go/storage.HMACKey 69 - cloud.google.com/go/storage.HMACKeyAttrsToUpdate 70 - cloud.google.com/go/storage.HMACKeyHandle 71 - cloud.google.com/go/storage.HMACKeyHandle.Delete 72 - cloud.google.com/go/storage.HMACKeyHandle.Get 73 - cloud.google.com/go/storage.HMACKeyHandle.Update 74 - cloud.google.com/go/storage.HMACKeyOption 75 - cloud.google.com/go/storage.HMACKeyOption.ForHMACKeyServiceAccountEmail 76 - cloud.google.com/go/storage.HMACKeyOption.ShowDeletedHMACKeys 77 - cloud.google.com/go/storage.HMACKeyOption.UserProjectForHMACKeys 78 - cloud.google.com/go/storage.HMACKeysIterator 79 - cloud.google.com/go/storage.HMACKeysIterator.Next 80 - cloud.google.com/go/storage.HMACKeysIterator.PageInfo 81 - cloud.google.com/go/storage.HMACState 82 - cloud.google.com/go/storage.Active,Inactive,Deleted 83 - cloud.google.com/go/storage.Lifecycle 84 - cloud.google.com/go/storage.LifecycleAction 85 - cloud.google.com/go/storage.LifecycleCondition 86 - cloud.google.com/go/storage.LifecycleRule 87 - cloud.google.com/go/storage.Liveness 88 - cloud.google.com/go/storage.LiveAndArchived,Live,Archived 89 - cloud.google.com/go/storage.Notification 90 - cloud.google.com/go/storage.ObjectAttrs 91 - cloud.google.com/go/storage.ObjectAttrsToUpdate 92 - cloud.google.com/go/storage.ObjectHandle 93 - cloud.google.com/go/storage.ObjectHandle.ACL 94 - cloud.google.com/go/storage.ObjectHandle.Attrs 95 - cloud.google.com/go/storage.ObjectHandle.BucketName 96 - cloud.google.com/go/storage.ObjectHandle.ComposerFrom 97 - cloud.google.com/go/storage.ObjectHandle.CopierFrom 98 - cloud.google.com/go/storage.ObjectHandle.Delete 99 - cloud.google.com/go/storage.ObjectHandle.Generation 100 - cloud.google.com/go/storage.ObjectHandle.If 101 - cloud.google.com/go/storage.ObjectHandle.Key 102 - cloud.google.com/go/storage.ObjectHandle.NewRangeReader 103 - cloud.google.com/go/storage.ObjectHandle.NewReader 104 - cloud.google.com/go/storage.ObjectHandle.NewWriter 105 - cloud.google.com/go/storage.ObjectHandle.ObjectName 106 - cloud.google.com/go/storage.ObjectHandle.ReadCompressed 107 - cloud.google.com/go/storage.ObjectHandle.Update 108 - cloud.google.com/go/storage.ObjectIterator 109 - cloud.google.com/go/storage.ObjectIterator.Next 110 - cloud.google.com/go/storage.ObjectIterator.PageInfo 111 - cloud.google.com/go/storage.PolicyV4Fields 112 - cloud.google.com/go/storage.PostPolicyV4 113 - cloud.google.com/go/storage.PostPolicyV4.GenerateSignedPostPolicyV4 114 - cloud.google.com/go/storage.PostPolicyV4Condition 115 - cloud.google.com/go/storage.PostPolicyV4Condition.ConditionContentLengthRange 116 - cloud.google.com/go/storage.PostPolicyV4Condition.ConditionStartsWith 117 - cloud.google.com/go/storage.PostPolicyV4Options 118 - cloud.google.com/go/storage.ProjectTeam 119 - cloud.google.com/go/storage.Query 120 - cloud.google.com/go/storage.Query.SetAttrSelection 121 - cloud.google.com/go/storage.Reader 122 - cloud.google.com/go/storage.Reader.CacheControl 123 - cloud.google.com/go/storage.Reader.Close 124 - cloud.google.com/go/storage.Reader.ContentEncoding 125 - cloud.google.com/go/storage.Reader.ContentType 126 - cloud.google.com/go/storage.Reader.LastModified 127 - cloud.google.com/go/storage.Reader.Read 128 - cloud.google.com/go/storage.Reader.Remain 129 - cloud.google.com/go/storage.Reader.Size 130 - cloud.google.com/go/storage.ReaderObjectAttrs 131 - cloud.google.com/go/storage.RetentionPolicy 132 - cloud.google.com/go/storage.SignedURLOptions 133 - cloud.google.com/go/storage.SigningScheme 134 - cloud.google.com/go/storage.SigningSchemeDefault,SigningSchemeV2,SigningSchemeV4 135 - cloud.google.com/go/storage.URLStyle 136 - cloud.google.com/go/storage.URLStyle.BucketBoundHostname 137 - cloud.google.com/go/storage.URLStyle.PathStyle 138 - cloud.google.com/go/storage.URLStyle.VirtualHostedStyle 139 - cloud.google.com/go/storage.UniformBucketLevelAccess 140 - cloud.google.com/go/storage.Writer 141 - cloud.google.com/go/storage.Writer.Attrs 142 - cloud.google.com/go/storage.Writer.Close 143 - cloud.google.com/go/storage.Writer.CloseWithError 144 - cloud.google.com/go/storage.Writer.Write 145 - cloud.google.com/go/storage.SignedURL 146- uid: cloud.google.com/go/storage.DeleteAction,SetStorageClassAction 147 name: DeleteAction, SetStorageClassAction 148 id: DeleteAction,SetStorageClassAction 149 parent: cloud.google.com/go/storage 150 type: const 151 langs: 152 - go 153 syntax: 154 content: "const (\n\n\t// DeleteAction is a lifecycle action that deletes a live and/or archived\n\t// objects. Takes precedence over SetStorageClass actions.\n\tDeleteAction = \"Delete\"\n\n\t// SetStorageClassAction changes the storage class of live and/or archived\n\t// objects.\n\tSetStorageClassAction = \"SetStorageClass\"\n)" 155- uid: cloud.google.com/go/storage.NoPayload,JSONPayload 156 name: NoPayload, JSONPayload 157 id: NoPayload,JSONPayload 158 summary: | 159 Values for Notification.PayloadFormat. 160 parent: cloud.google.com/go/storage 161 type: const 162 langs: 163 - go 164 syntax: 165 content: "const (\n\t// Send no payload with notification messages.\n\tNoPayload = \"NONE\"\n\n\t// Send object metadata as JSON with notification messages.\n\tJSONPayload = \"JSON_API_V1\"\n)" 166- uid: cloud.google.com/go/storage.ObjectFinalizeEvent,ObjectMetadataUpdateEvent,ObjectDeleteEvent,ObjectArchiveEvent 167 name: ObjectFinalizeEvent, ObjectMetadataUpdateEvent, ObjectDeleteEvent, ObjectArchiveEvent 168 id: ObjectFinalizeEvent,ObjectMetadataUpdateEvent,ObjectDeleteEvent,ObjectArchiveEvent 169 summary: | 170 Values for Notification.EventTypes. 171 parent: cloud.google.com/go/storage 172 type: const 173 langs: 174 - go 175 syntax: 176 content: "const (\n\t// Event that occurs when an object is successfully created.\n\tObjectFinalizeEvent = \"OBJECT_FINALIZE\"\n\n\t// Event that occurs when the metadata of an existing object changes.\n\tObjectMetadataUpdateEvent = \"OBJECT_METADATA_UPDATE\"\n\n\t// Event that occurs when an object is permanently deleted.\n\tObjectDeleteEvent = \"OBJECT_DELETE\"\n\n\t// Event that occurs when the live version of an object becomes an\n\t// archived version.\n\tObjectArchiveEvent = \"OBJECT_ARCHIVE\"\n)" 177- uid: cloud.google.com/go/storage.ScopeFullControl,ScopeReadOnly,ScopeReadWrite 178 name: ScopeFullControl, ScopeReadOnly, ScopeReadWrite 179 id: ScopeFullControl,ScopeReadOnly,ScopeReadWrite 180 parent: cloud.google.com/go/storage 181 type: const 182 langs: 183 - go 184 syntax: 185 content: "const (\n\t// ScopeFullControl grants permissions to manage your\n\t// data and permissions in Google Cloud Storage.\n\tScopeFullControl = raw.DevstorageFullControlScope\n\n\t// ScopeReadOnly grants permissions to\n\t// view your data in Google Cloud Storage.\n\tScopeReadOnly = raw.DevstorageReadOnlyScope\n\n\t// ScopeReadWrite grants permissions to manage your\n\t// data in Google Cloud Storage.\n\tScopeReadWrite = raw.DevstorageReadWriteScope\n)" 186- uid: cloud.google.com/go/storage.ErrBucketNotExist,ErrObjectNotExist 187 name: ErrBucketNotExist, ErrObjectNotExist 188 id: ErrBucketNotExist,ErrObjectNotExist 189 parent: cloud.google.com/go/storage 190 type: variable 191 langs: 192 - go 193 syntax: 194 content: "var (\n\t// ErrBucketNotExist indicates that the bucket does not exist.\n\tErrBucketNotExist = errors.New(\"storage: bucket doesn't exist\")\n\t// ErrObjectNotExist indicates that the object does not exist.\n\tErrObjectNotExist = errors.New(\"storage: object doesn't exist\")\n)" 195- uid: cloud.google.com/go/storage.ACLEntity 196 name: ACLEntity 197 id: ACLEntity 198 summary: | 199 ACLEntity refers to a user or group. 200 They are sometimes referred to as grantees. 201 202 It could be in the form of: 203 "user-<userId>", "user-<email>", "group-<groupId>", "group-<email>", 204 "domain-<domain>" and "project-team-<projectId>". 205 206 Or one of the predefined constants: AllUsers, AllAuthenticatedUsers. 207 parent: cloud.google.com/go/storage 208 type: type 209 langs: 210 - go 211 syntax: 212 content: type ACLEntity string 213- uid: cloud.google.com/go/storage.AllUsers,AllAuthenticatedUsers 214 name: AllUsers, AllAuthenticatedUsers 215 id: AllUsers,AllAuthenticatedUsers 216 parent: cloud.google.com/go/storage.ACLEntity 217 type: const 218 langs: 219 - go 220 syntax: 221 content: "const (\n\tAllUsers ACLEntity = \"allUsers\"\n\tAllAuthenticatedUsers ACLEntity = \"allAuthenticatedUsers\"\n)" 222- uid: cloud.google.com/go/storage.ACLHandle 223 name: ACLHandle 224 id: ACLHandle 225 summary: | 226 ACLHandle provides operations on an access control list for a Google Cloud Storage bucket or object. 227 parent: cloud.google.com/go/storage 228 type: type 229 langs: 230 - go 231 syntax: 232 content: "type ACLHandle struct {\n\t// contains filtered or unexported fields\n}" 233- uid: cloud.google.com/go/storage.ACLHandle.Delete 234 name: | 235 func (*ACLHandle) Delete 236 id: Delete 237 summary: | 238 Delete permanently deletes the ACL entry for the given entity. 239 parent: cloud.google.com/go/storage.ACLHandle 240 type: function 241 langs: 242 - go 243 syntax: 244 content: func (a *ACLHandle) Delete(ctx context.Context, entity ACLEntity) (err error) 245 codeexamples: 246 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\t// No longer grant access to the bucket to everyone on the Internet.\n\tif err := client.Bucket(\"my-bucket\").ACL().Delete(ctx, storage.AllUsers); err != nil {\n\t\t// TODO: handle error.\n\t}\n}\n" 247- uid: cloud.google.com/go/storage.ACLHandle.List 248 name: | 249 func (*ACLHandle) List 250 id: List 251 summary: | 252 List retrieves ACL entries. 253 parent: cloud.google.com/go/storage.ACLHandle 254 type: function 255 langs: 256 - go 257 syntax: 258 content: func (a *ACLHandle) List(ctx context.Context) (rules []ACLRule, err error) 259 codeexamples: 260 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\t// List the default object ACLs for my-bucket.\n\taclRules, err := client.Bucket(\"my-bucket\").DefaultObjectACL().List(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Println(aclRules)\n}\n" 261- uid: cloud.google.com/go/storage.ACLHandle.Set 262 name: | 263 func (*ACLHandle) Set 264 id: Set 265 summary: | 266 Set sets the role for the given entity. 267 parent: cloud.google.com/go/storage.ACLHandle 268 type: function 269 langs: 270 - go 271 syntax: 272 content: func (a *ACLHandle) Set(ctx context.Context, entity ACLEntity, role ACLRole) (err error) 273 codeexamples: 274 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\t// Let any authenticated user read my-bucket/my-object.\n\tobj := client.Bucket(\"my-bucket\").Object(\"my-object\")\n\tif err := obj.ACL().Set(ctx, storage.AllAuthenticatedUsers, storage.RoleReader); err != nil {\n\t\t// TODO: handle error.\n\t}\n}\n" 275- uid: cloud.google.com/go/storage.ACLRole 276 name: ACLRole 277 id: ACLRole 278 summary: | 279 ACLRole is the level of access to grant. 280 parent: cloud.google.com/go/storage 281 type: type 282 langs: 283 - go 284 syntax: 285 content: type ACLRole string 286- uid: cloud.google.com/go/storage.RoleOwner,RoleReader,RoleWriter 287 name: RoleOwner, RoleReader, RoleWriter 288 id: RoleOwner,RoleReader,RoleWriter 289 parent: cloud.google.com/go/storage.ACLRole 290 type: const 291 langs: 292 - go 293 syntax: 294 content: "const (\n\tRoleOwner ACLRole = \"OWNER\"\n\tRoleReader ACLRole = \"READER\"\n\tRoleWriter ACLRole = \"WRITER\"\n)" 295- uid: cloud.google.com/go/storage.ACLRule 296 name: ACLRule 297 id: ACLRule 298 summary: | 299 ACLRule represents a grant for a role to an entity (user, group or team) for a 300 Google Cloud Storage object or bucket. 301 parent: cloud.google.com/go/storage 302 type: type 303 langs: 304 - go 305 syntax: 306 content: "type ACLRule struct {\n\tEntity ACLEntity\n\tEntityID string\n\tRole ACLRole\n\tDomain string\n\tEmail string\n\tProjectTeam *ProjectTeam\n}" 307- uid: cloud.google.com/go/storage.BucketAttrs 308 name: BucketAttrs 309 id: BucketAttrs 310 summary: | 311 BucketAttrs represents the metadata for a Google Cloud Storage bucket. 312 Read-only fields are ignored by BucketHandle.Create. 313 parent: cloud.google.com/go/storage 314 type: type 315 langs: 316 - go 317 syntax: 318 content: "type BucketAttrs struct {\n\t// Name is the name of the bucket.\n\t// This field is read-only.\n\tName string\n\n\t// ACL is the list of access control rules on the bucket.\n\tACL []ACLRule\n\n\t// BucketPolicyOnly is an alias for UniformBucketLevelAccess. Use of\n\t// UniformBucketLevelAccess is recommended above the use of this field.\n\t// Setting BucketPolicyOnly.Enabled OR UniformBucketLevelAccess.Enabled to\n\t// true, will enable UniformBucketLevelAccess.\n\tBucketPolicyOnly BucketPolicyOnly\n\n\t// UniformBucketLevelAccess configures access checks to use only bucket-level IAM\n\t// policies and ignore any ACL rules for the bucket.\n\t// See https://cloud.google.com/storage/docs/uniform-bucket-level-access\n\t// for more information.\n\tUniformBucketLevelAccess UniformBucketLevelAccess\n\n\t// DefaultObjectACL is the list of access controls to\n\t// apply to new objects when no object ACL is provided.\n\tDefaultObjectACL []ACLRule\n\n\t// DefaultEventBasedHold is the default value for event-based hold on\n\t// newly created objects in this bucket. It defaults to false.\n\tDefaultEventBasedHold bool\n\n\t// If not empty, applies a predefined set of access controls. It should be set\n\t// only when creating a bucket.\n\t// It is always empty for BucketAttrs returned from the service.\n\t// See https://cloud.google.com/storage/docs/json_api/v1/buckets/insert\n\t// for valid values.\n\tPredefinedACL string\n\n\t// If not empty, applies a predefined set of default object access controls.\n\t// It should be set only when creating a bucket.\n\t// It is always empty for BucketAttrs returned from the service.\n\t// See https://cloud.google.com/storage/docs/json_api/v1/buckets/insert\n\t// for valid values.\n\tPredefinedDefaultObjectACL string\n\n\t// Location is the location of the bucket. It defaults to \"US\".\n\tLocation string\n\n\t// MetaGeneration is the metadata generation of the bucket.\n\t// This field is read-only.\n\tMetaGeneration int64\n\n\t// StorageClass is the default storage class of the bucket. This defines\n\t// how objects in the bucket are stored and determines the SLA\n\t// and the cost of storage. Typical values are \"STANDARD\", \"NEARLINE\",\n\t// \"COLDLINE\" and \"ARCHIVE\". Defaults to \"STANDARD\".\n\t// See https://cloud.google.com/storage/docs/storage-classes for all\n\t// valid values.\n\tStorageClass string\n\n\t// Created is the creation time of the bucket.\n\t// This field is read-only.\n\tCreated time.Time\n\n\t// VersioningEnabled reports whether this bucket has versioning enabled.\n\tVersioningEnabled bool\n\n\t// Labels are the bucket's labels.\n\tLabels map[string]string\n\n\t// RequesterPays reports whether the bucket is a Requester Pays bucket.\n\t// Clients performing operations on Requester Pays buckets must provide\n\t// a user project (see BucketHandle.UserProject), which will be billed\n\t// for the operations.\n\tRequesterPays bool\n\n\t// Lifecycle is the lifecycle configuration for objects in the bucket.\n\tLifecycle Lifecycle\n\n\t// Retention policy enforces a minimum retention time for all objects\n\t// contained in the bucket. A RetentionPolicy of nil implies the bucket\n\t// has no minimum data retention.\n\t//\n\t// This feature is in private alpha release. It is not currently available to\n\t// most customers. It might be changed in backwards-incompatible ways and is not\n\t// subject to any SLA or deprecation policy.\n\tRetentionPolicy *RetentionPolicy\n\n\t// The bucket's Cross-Origin Resource Sharing (CORS) configuration.\n\tCORS []CORS\n\n\t// The encryption configuration used by default for newly inserted objects.\n\tEncryption *BucketEncryption\n\n\t// The logging configuration.\n\tLogging *BucketLogging\n\n\t// The website configuration.\n\tWebsite *BucketWebsite\n\n\t// Etag is the HTTP/1.1 Entity tag for the bucket.\n\t// This field is read-only.\n\tEtag string\n\n\t// LocationType describes how data is stored and replicated.\n\t// Typical values are \"multi-region\", \"region\" and \"dual-region\".\n\t// This field is read-only.\n\tLocationType string\n}" 319- uid: cloud.google.com/go/storage.BucketAttrsToUpdate 320 name: BucketAttrsToUpdate 321 id: BucketAttrsToUpdate 322 summary: | 323 BucketAttrsToUpdate define the attributes to update during an Update call. 324 parent: cloud.google.com/go/storage 325 type: type 326 langs: 327 - go 328 syntax: 329 content: "type BucketAttrsToUpdate struct {\n\t// If set, updates whether the bucket uses versioning.\n\tVersioningEnabled optional.Bool\n\n\t// If set, updates whether the bucket is a Requester Pays bucket.\n\tRequesterPays optional.Bool\n\n\t// DefaultEventBasedHold is the default value for event-based hold on\n\t// newly created objects in this bucket.\n\tDefaultEventBasedHold optional.Bool\n\n\t// BucketPolicyOnly is an alias for UniformBucketLevelAccess. Use of\n\t// UniformBucketLevelAccess is recommended above the use of this field.\n\t// Setting BucketPolicyOnly.Enabled OR UniformBucketLevelAccess.Enabled to\n\t// true, will enable UniformBucketLevelAccess. If both BucketPolicyOnly and\n\t// UniformBucketLevelAccess are set, the value of UniformBucketLevelAccess\n\t// will take precedence.\n\tBucketPolicyOnly *BucketPolicyOnly\n\n\t// UniformBucketLevelAccess configures access checks to use only bucket-level IAM\n\t// policies and ignore any ACL rules for the bucket.\n\t// See https://cloud.google.com/storage/docs/uniform-bucket-level-access\n\t// for more information.\n\tUniformBucketLevelAccess *UniformBucketLevelAccess\n\n\t// If set, updates the retention policy of the bucket. Using\n\t// RetentionPolicy.RetentionPeriod = 0 will delete the existing policy.\n\t//\n\t// This feature is in private alpha release. It is not currently available to\n\t// most customers. It might be changed in backwards-incompatible ways and is not\n\t// subject to any SLA or deprecation policy.\n\tRetentionPolicy *RetentionPolicy\n\n\t// If set, replaces the CORS configuration with a new configuration.\n\t// An empty (rather than nil) slice causes all CORS policies to be removed.\n\tCORS []CORS\n\n\t// If set, replaces the encryption configuration of the bucket. Using\n\t// BucketEncryption.DefaultKMSKeyName = \"\" will delete the existing\n\t// configuration.\n\tEncryption *BucketEncryption\n\n\t// If set, replaces the lifecycle configuration of the bucket.\n\tLifecycle *Lifecycle\n\n\t// If set, replaces the logging configuration of the bucket.\n\tLogging *BucketLogging\n\n\t// If set, replaces the website configuration of the bucket.\n\tWebsite *BucketWebsite\n\n\t// If not empty, applies a predefined set of access controls.\n\t// See https://cloud.google.com/storage/docs/json_api/v1/buckets/patch.\n\tPredefinedACL string\n\n\t// If not empty, applies a predefined set of default object access controls.\n\t// See https://cloud.google.com/storage/docs/json_api/v1/buckets/patch.\n\tPredefinedDefaultObjectACL string\n\t// contains filtered or unexported fields\n}" 330- uid: cloud.google.com/go/storage.BucketAttrsToUpdate.DeleteLabel 331 name: | 332 func (*BucketAttrsToUpdate) DeleteLabel 333 id: DeleteLabel 334 summary: | 335 DeleteLabel causes a label to be deleted when ua is used in a 336 call to Bucket.Update. 337 parent: cloud.google.com/go/storage.BucketAttrsToUpdate 338 type: function 339 langs: 340 - go 341 syntax: 342 content: func (ua *BucketAttrsToUpdate) DeleteLabel(name string) 343- uid: cloud.google.com/go/storage.BucketAttrsToUpdate.SetLabel 344 name: | 345 func (*BucketAttrsToUpdate) SetLabel 346 id: SetLabel 347 summary: | 348 SetLabel causes a label to be added or modified when ua is used 349 in a call to Bucket.Update. 350 parent: cloud.google.com/go/storage.BucketAttrsToUpdate 351 type: function 352 langs: 353 - go 354 syntax: 355 content: func (ua *BucketAttrsToUpdate) SetLabel(name, value string) 356- uid: cloud.google.com/go/storage.BucketConditions 357 name: BucketConditions 358 id: BucketConditions 359 summary: | 360 BucketConditions constrain bucket methods to act on specific metagenerations. 361 362 The zero value is an empty set of constraints. 363 parent: cloud.google.com/go/storage 364 type: type 365 langs: 366 - go 367 syntax: 368 content: "type BucketConditions struct {\n\t// MetagenerationMatch specifies that the bucket must have the given\n\t// metageneration for the operation to occur.\n\t// If MetagenerationMatch is zero, it has no effect.\n\tMetagenerationMatch int64\n\n\t// MetagenerationNotMatch specifies that the bucket must not have the given\n\t// metageneration for the operation to occur.\n\t// If MetagenerationNotMatch is zero, it has no effect.\n\tMetagenerationNotMatch int64\n}" 369- uid: cloud.google.com/go/storage.BucketEncryption 370 name: BucketEncryption 371 id: BucketEncryption 372 summary: | 373 BucketEncryption is a bucket's encryption configuration. 374 parent: cloud.google.com/go/storage 375 type: type 376 langs: 377 - go 378 syntax: 379 content: "type BucketEncryption struct {\n\t// A Cloud KMS key name, in the form\n\t// projects/P/locations/L/keyRings/R/cryptoKeys/K, that will be used to encrypt\n\t// objects inserted into this bucket, if no encryption method is specified.\n\t// The key's location must be the same as the bucket's.\n\tDefaultKMSKeyName string\n}" 380- uid: cloud.google.com/go/storage.BucketHandle 381 name: BucketHandle 382 id: BucketHandle 383 summary: | 384 BucketHandle provides operations on a Google Cloud Storage bucket. 385 Use Client.Bucket to get a handle. 386 parent: cloud.google.com/go/storage 387 type: type 388 langs: 389 - go 390 syntax: 391 content: "type BucketHandle struct {\n\t// contains filtered or unexported fields\n}" 392 codeexamples: 393 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\n\tattrs, err := client.Bucket(\"my-bucket\").Attrs(ctx)\n\tif err == storage.ErrBucketNotExist {\n\t\tfmt.Println(\"The bucket does not exist\")\n\t\treturn\n\t}\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Printf(\"The bucket exists and has attributes: %#v\\n\", attrs)\n}\n" 394 name: exists 395- uid: cloud.google.com/go/storage.BucketHandle.ACL 396 name: | 397 func (*BucketHandle) ACL 398 id: ACL 399 summary: | 400 ACL returns an ACLHandle, which provides access to the bucket's access control list. 401 This controls who can list, create or overwrite the objects in a bucket. 402 This call does not perform any network operations. 403 parent: cloud.google.com/go/storage.BucketHandle 404 type: function 405 langs: 406 - go 407 syntax: 408 content: func (b *BucketHandle) ACL() *ACLHandle 409- uid: cloud.google.com/go/storage.BucketHandle.AddNotification 410 name: | 411 func (*BucketHandle) AddNotification 412 id: AddNotification 413 summary: | 414 AddNotification adds a notification to b. You must set n's TopicProjectID, TopicID 415 and PayloadFormat, and must not set its ID. The other fields are all optional. The 416 returned Notification's ID can be used to refer to it. 417 parent: cloud.google.com/go/storage.BucketHandle 418 type: function 419 langs: 420 - go 421 syntax: 422 content: func (b *BucketHandle) AddNotification(ctx context.Context, n *Notification) (ret *Notification, err error) 423 codeexamples: 424 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tb := client.Bucket(\"my-bucket\")\n\tn, err := b.AddNotification(ctx, &storage.Notification{\n\t\tTopicProjectID: \"my-project\",\n\t\tTopicID: \"my-topic\",\n\t\tPayloadFormat: storage.JSONPayload,\n\t})\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Println(n.ID)\n}\n" 425- uid: cloud.google.com/go/storage.BucketHandle.Attrs 426 name: | 427 func (*BucketHandle) Attrs 428 id: Attrs 429 summary: | 430 Attrs returns the metadata for the bucket. 431 parent: cloud.google.com/go/storage.BucketHandle 432 type: function 433 langs: 434 - go 435 syntax: 436 content: func (b *BucketHandle) Attrs(ctx context.Context) (attrs *BucketAttrs, err error) 437 codeexamples: 438 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tattrs, err := client.Bucket(\"my-bucket\").Attrs(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Println(attrs)\n}\n" 439- uid: cloud.google.com/go/storage.BucketHandle.Create 440 name: | 441 func (*BucketHandle) Create 442 id: Create 443 summary: | 444 Create creates the Bucket in the project. 445 If attrs is nil the API defaults will be used. 446 parent: cloud.google.com/go/storage.BucketHandle 447 type: function 448 langs: 449 - go 450 syntax: 451 content: func (b *BucketHandle) Create(ctx context.Context, projectID string, attrs *BucketAttrs) (err error) 452 codeexamples: 453 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tif err := client.Bucket(\"my-bucket\").Create(ctx, \"my-project\", nil); err != nil {\n\t\t// TODO: handle error.\n\t}\n}\n" 454- uid: cloud.google.com/go/storage.BucketHandle.DefaultObjectACL 455 name: | 456 func (*BucketHandle) DefaultObjectACL 457 id: DefaultObjectACL 458 summary: | 459 DefaultObjectACL returns an ACLHandle, which provides access to the bucket's default object ACLs. 460 These ACLs are applied to newly created objects in this bucket that do not have a defined ACL. 461 This call does not perform any network operations. 462 parent: cloud.google.com/go/storage.BucketHandle 463 type: function 464 langs: 465 - go 466 syntax: 467 content: func (b *BucketHandle) DefaultObjectACL() *ACLHandle 468- uid: cloud.google.com/go/storage.BucketHandle.Delete 469 name: | 470 func (*BucketHandle) Delete 471 id: Delete 472 summary: | 473 Delete deletes the Bucket. 474 parent: cloud.google.com/go/storage.BucketHandle 475 type: function 476 langs: 477 - go 478 syntax: 479 content: func (b *BucketHandle) Delete(ctx context.Context) (err error) 480 codeexamples: 481 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tif err := client.Bucket(\"my-bucket\").Delete(ctx); err != nil {\n\t\t// TODO: handle error.\n\t}\n}\n" 482- uid: cloud.google.com/go/storage.BucketHandle.DeleteNotification 483 name: | 484 func (*BucketHandle) DeleteNotification 485 id: DeleteNotification 486 summary: | 487 DeleteNotification deletes the notification with the given ID. 488 parent: cloud.google.com/go/storage.BucketHandle 489 type: function 490 langs: 491 - go 492 syntax: 493 content: func (b *BucketHandle) DeleteNotification(ctx context.Context, id string) (err error) 494 codeexamples: 495 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nvar notificationID string\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tb := client.Bucket(\"my-bucket\")\n\t// TODO: Obtain notificationID from BucketHandle.AddNotification\n\t// or BucketHandle.Notifications.\n\terr = b.DeleteNotification(ctx, notificationID)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n}\n" 496- uid: cloud.google.com/go/storage.BucketHandle.IAM 497 name: | 498 func (*BucketHandle) IAM 499 id: IAM 500 summary: | 501 IAM provides access to IAM access control for the bucket. 502 parent: cloud.google.com/go/storage.BucketHandle 503 type: function 504 langs: 505 - go 506 syntax: 507 content: func (b *BucketHandle) IAM() *iam.Handle 508- uid: cloud.google.com/go/storage.BucketHandle.If 509 name: | 510 func (*BucketHandle) If 511 id: If 512 summary: | 513 If returns a new BucketHandle that applies a set of preconditions. 514 Preconditions already set on the BucketHandle are ignored. 515 Operations on the new handle will return an error if the preconditions are not 516 satisfied. The only valid preconditions for buckets are MetagenerationMatch 517 and MetagenerationNotMatch. 518 parent: cloud.google.com/go/storage.BucketHandle 519 type: function 520 langs: 521 - go 522 syntax: 523 content: func (b *BucketHandle) If(conds BucketConditions) *BucketHandle 524- uid: cloud.google.com/go/storage.BucketHandle.LockRetentionPolicy 525 name: | 526 func (*BucketHandle) LockRetentionPolicy 527 id: LockRetentionPolicy 528 summary: | 529 LockRetentionPolicy locks a bucket's retention policy until a previously-configured 530 RetentionPeriod past the EffectiveTime. Note that if RetentionPeriod is set to less 531 than a day, the retention policy is treated as a development configuration and locking 532 will have no effect. The BucketHandle must have a metageneration condition that 533 matches the bucket's metageneration. See BucketHandle.If. 534 535 This feature is in private alpha release. It is not currently available to 536 most customers. It might be changed in backwards-incompatible ways and is not 537 subject to any SLA or deprecation policy. 538 parent: cloud.google.com/go/storage.BucketHandle 539 type: function 540 langs: 541 - go 542 syntax: 543 content: func (b *BucketHandle) LockRetentionPolicy(ctx context.Context) error 544 codeexamples: 545 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tb := client.Bucket(\"my-bucket\")\n\tattrs, err := b.Attrs(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\t// Note that locking the bucket without first attaching a RetentionPolicy\n\t// that's at least 1 day is a no-op\n\terr = b.If(storage.BucketConditions{MetagenerationMatch: attrs.MetaGeneration}).LockRetentionPolicy(ctx)\n\tif err != nil {\n\t\t// TODO: handle err\n\t}\n}\n" 546- uid: cloud.google.com/go/storage.BucketHandle.Notifications 547 name: | 548 func (*BucketHandle) Notifications 549 id: Notifications 550 summary: | 551 Notifications returns all the Notifications configured for this bucket, as a map 552 indexed by notification ID. 553 parent: cloud.google.com/go/storage.BucketHandle 554 type: function 555 langs: 556 - go 557 syntax: 558 content: func (b *BucketHandle) Notifications(ctx context.Context) (n map[string]*Notification, err error) 559 codeexamples: 560 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tb := client.Bucket(\"my-bucket\")\n\tns, err := b.Notifications(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfor id, n := range ns {\n\t\tfmt.Printf(\"%s: %+v\\n\", id, n)\n\t}\n}\n" 561- uid: cloud.google.com/go/storage.BucketHandle.Object 562 name: | 563 func (*BucketHandle) Object 564 id: Object 565 summary: | 566 Object returns an ObjectHandle, which provides operations on the named object. 567 This call does not perform any network operations. 568 569 name must consist entirely of valid UTF-8-encoded runes. The full specification 570 for valid object names can be found at: 571 https://cloud.google.com/storage/docs/bucket-naming 572 parent: cloud.google.com/go/storage.BucketHandle 573 type: function 574 langs: 575 - go 576 syntax: 577 content: func (b *BucketHandle) Object(name string) *ObjectHandle 578- uid: cloud.google.com/go/storage.BucketHandle.Objects 579 name: | 580 func (*BucketHandle) Objects 581 id: Objects 582 summary: | 583 Objects returns an iterator over the objects in the bucket that match the Query q. 584 If q is nil, no filtering is done. 585 586 Note: The returned iterator is not safe for concurrent operations without explicit synchronization. 587 parent: cloud.google.com/go/storage.BucketHandle 588 type: function 589 langs: 590 - go 591 syntax: 592 content: func (b *BucketHandle) Objects(ctx context.Context, q *Query) *ObjectIterator 593 codeexamples: 594 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tit := client.Bucket(\"my-bucket\").Objects(ctx, nil)\n\t_ = it // TODO: iterate using Next or iterator.Pager.\n}\n" 595- uid: cloud.google.com/go/storage.BucketHandle.Update 596 name: | 597 func (*BucketHandle) Update 598 id: Update 599 summary: | 600 Update updates a bucket's attributes. 601 parent: cloud.google.com/go/storage.BucketHandle 602 type: function 603 langs: 604 - go 605 syntax: 606 content: func (b *BucketHandle) Update(ctx context.Context, uattrs BucketAttrsToUpdate) (attrs *BucketAttrs, err error) 607 codeexamples: 608 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\t// Enable versioning in the bucket, regardless of its previous value.\n\tattrs, err := client.Bucket(\"my-bucket\").Update(ctx,\n\t\tstorage.BucketAttrsToUpdate{VersioningEnabled: true})\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Println(attrs)\n}\n" 609 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tb := client.Bucket(\"my-bucket\")\n\tattrs, err := b.Attrs(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tvar au storage.BucketAttrsToUpdate\n\tau.SetLabel(\"lab\", attrs.Labels[\"lab\"]+\"-more\")\n\tif attrs.Labels[\"delete-me\"] == \"yes\" {\n\t\tau.DeleteLabel(\"delete-me\")\n\t}\n\tattrs, err = b.\n\t\tIf(storage.BucketConditions{MetagenerationMatch: attrs.MetaGeneration}).\n\t\tUpdate(ctx, au)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Println(attrs)\n}\n" 610 name: readModifyWrite 611- uid: cloud.google.com/go/storage.BucketHandle.UserProject 612 name: | 613 func (*BucketHandle) UserProject 614 id: UserProject 615 summary: | 616 UserProject returns a new BucketHandle that passes the project ID as the user 617 project for all subsequent calls. Calls with a user project will be billed to that 618 project rather than to the bucket's owning project. 619 620 A user project is required for all operations on Requester Pays buckets. 621 parent: cloud.google.com/go/storage.BucketHandle 622 type: function 623 langs: 624 - go 625 syntax: 626 content: func (b *BucketHandle) UserProject(projectID string) *BucketHandle 627- uid: cloud.google.com/go/storage.BucketIterator 628 name: BucketIterator 629 id: BucketIterator 630 summary: | 631 A BucketIterator is an iterator over BucketAttrs. 632 633 Note: This iterator is not safe for concurrent operations without explicit synchronization. 634 parent: cloud.google.com/go/storage 635 type: type 636 langs: 637 - go 638 syntax: 639 content: "type BucketIterator struct {\n\t// Prefix restricts the iterator to buckets whose names begin with it.\n\tPrefix string\n\t// contains filtered or unexported fields\n}" 640- uid: cloud.google.com/go/storage.BucketIterator.Next 641 name: | 642 func (*BucketIterator) Next 643 id: Next 644 summary: | 645 Next returns the next result. Its second return value is iterator.Done if 646 there are no more results. Once Next returns iterator.Done, all subsequent 647 calls will return iterator.Done. 648 649 Note: This method is not safe for concurrent operations without explicit synchronization. 650 parent: cloud.google.com/go/storage.BucketIterator 651 type: function 652 langs: 653 - go 654 syntax: 655 content: func (it *BucketIterator) Next() (*BucketAttrs, error) 656 codeexamples: 657 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n\t\"google.golang.org/api/iterator\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tit := client.Buckets(ctx, \"my-project\")\n\tfor {\n\t\tbucketAttrs, err := it.Next()\n\t\tif err == iterator.Done {\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\t// TODO: Handle error.\n\t\t}\n\t\tfmt.Println(bucketAttrs)\n\t}\n}\n" 658- uid: cloud.google.com/go/storage.BucketIterator.PageInfo 659 name: | 660 func (*BucketIterator) PageInfo 661 id: PageInfo 662 summary: | 663 PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 664 665 Note: This method is not safe for concurrent operations without explicit synchronization. 666 parent: cloud.google.com/go/storage.BucketIterator 667 type: function 668 langs: 669 - go 670 syntax: 671 content: func (it *BucketIterator) PageInfo() *iterator.PageInfo 672- uid: cloud.google.com/go/storage.BucketLogging 673 name: BucketLogging 674 id: BucketLogging 675 summary: | 676 BucketLogging holds the bucket's logging configuration, which defines the 677 destination bucket and optional name prefix for the current bucket's 678 logs. 679 parent: cloud.google.com/go/storage 680 type: type 681 langs: 682 - go 683 syntax: 684 content: "type BucketLogging struct {\n\t// The destination bucket where the current bucket's logs\n\t// should be placed.\n\tLogBucket string\n\n\t// A prefix for log object names.\n\tLogObjectPrefix string\n}" 685- uid: cloud.google.com/go/storage.BucketPolicyOnly 686 name: BucketPolicyOnly 687 id: BucketPolicyOnly 688 summary: | 689 BucketPolicyOnly is an alias for UniformBucketLevelAccess. 690 Use of UniformBucketLevelAccess is preferred above BucketPolicyOnly. 691 parent: cloud.google.com/go/storage 692 type: type 693 langs: 694 - go 695 syntax: 696 content: "type BucketPolicyOnly struct {\n\t// Enabled specifies whether access checks use only bucket-level IAM\n\t// policies. Enabled may be disabled until the locked time.\n\tEnabled bool\n\t// LockedTime specifies the deadline for changing Enabled from true to\n\t// false.\n\tLockedTime time.Time\n}" 697- uid: cloud.google.com/go/storage.BucketWebsite 698 name: BucketWebsite 699 id: BucketWebsite 700 summary: | 701 BucketWebsite holds the bucket's website configuration, controlling how the 702 service behaves when accessing bucket contents as a web site. See 703 https://cloud.google.com/storage/docs/static-website for more information. 704 parent: cloud.google.com/go/storage 705 type: type 706 langs: 707 - go 708 syntax: 709 content: "type BucketWebsite struct {\n\t// If the requested object path is missing, the service will ensure the path has\n\t// a trailing '/', append this suffix, and attempt to retrieve the resulting\n\t// object. This allows the creation of index.html objects to represent directory\n\t// pages.\n\tMainPageSuffix string\n\n\t// If the requested object path is missing, and any mainPageSuffix object is\n\t// missing, if applicable, the service will return the named object from this\n\t// bucket as the content for a 404 Not Found result.\n\tNotFoundPage string\n}" 710- uid: cloud.google.com/go/storage.CORS 711 name: CORS 712 id: CORS 713 summary: | 714 CORS is the bucket's Cross-Origin Resource Sharing (CORS) configuration. 715 parent: cloud.google.com/go/storage 716 type: type 717 langs: 718 - go 719 syntax: 720 content: "type CORS struct {\n\t// MaxAge is the value to return in the Access-Control-Max-Age\n\t// header used in preflight responses.\n\tMaxAge time.Duration\n\n\t// Methods is the list of HTTP methods on which to include CORS response\n\t// headers, (GET, OPTIONS, POST, etc) Note: \"*\" is permitted in the list\n\t// of methods, and means \"any method\".\n\tMethods []string\n\n\t// Origins is the list of Origins eligible to receive CORS response\n\t// headers. Note: \"*\" is permitted in the list of origins, and means\n\t// \"any Origin\".\n\tOrigins []string\n\n\t// ResponseHeaders is the list of HTTP headers other than the simple\n\t// response headers to give permission for the user-agent to share\n\t// across domains.\n\tResponseHeaders []string\n}" 721- uid: cloud.google.com/go/storage.Client 722 name: Client 723 id: Client 724 summary: | 725 Client is a client for interacting with Google Cloud Storage. 726 727 Clients should be reused instead of created as needed. 728 The methods of Client are safe for concurrent use by multiple goroutines. 729 parent: cloud.google.com/go/storage 730 type: type 731 langs: 732 - go 733 syntax: 734 content: "type Client struct {\n\t// contains filtered or unexported fields\n}" 735- uid: cloud.google.com/go/storage.Client.NewClient 736 name: | 737 func NewClient 738 id: NewClient 739 summary: | 740 NewClient creates a new Google Cloud Storage client. 741 The default scope is ScopeFullControl. To use a different scope, like 742 ScopeReadOnly, use option.WithScopes. 743 744 Clients should be reused instead of created as needed. The methods of Client 745 are safe for concurrent use by multiple goroutines. 746 parent: cloud.google.com/go/storage.Client 747 type: function 748 langs: 749 - go 750 syntax: 751 content: func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) 752 codeexamples: 753 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\t// Use Google Application Default Credentials to authorize and authenticate the client.\n\t// More information about Application Default Credentials and how to enable is at\n\t// https://developers.google.com/identity/protocols/application-default-credentials.\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\t// Use the client.\n\n\t// Close the client when finished.\n\tif err := client.Close(); err != nil {\n\t\t// TODO: handle error.\n\t}\n}\n" 754 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"google.golang.org/api/option\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx, option.WithoutAuthentication())\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\t// Use the client.\n\n\t// Close the client when finished.\n\tif err := client.Close(); err != nil {\n\t\t// TODO: handle error.\n\t}\n}\n" 755 name: unauthenticated 756- uid: cloud.google.com/go/storage.Client.Bucket 757 name: | 758 func (*Client) Bucket 759 id: Bucket 760 summary: | 761 Bucket returns a BucketHandle, which provides operations on the named bucket. 762 This call does not perform any network operations. 763 764 The supplied name must contain only lowercase letters, numbers, dashes, 765 underscores, and dots. The full specification for valid bucket names can be 766 found at: 767 https://cloud.google.com/storage/docs/bucket-naming 768 parent: cloud.google.com/go/storage.Client 769 type: function 770 langs: 771 - go 772 syntax: 773 content: func (c *Client) Bucket(name string) *BucketHandle 774- uid: cloud.google.com/go/storage.Client.Buckets 775 name: | 776 func (*Client) Buckets 777 id: Buckets 778 summary: | 779 Buckets returns an iterator over the buckets in the project. You may 780 optionally set the iterator's Prefix field to restrict the list to buckets 781 whose names begin with the prefix. By default, all buckets in the project 782 are returned. 783 784 Note: The returned iterator is not safe for concurrent operations without explicit synchronization. 785 parent: cloud.google.com/go/storage.Client 786 type: function 787 langs: 788 - go 789 syntax: 790 content: func (c *Client) Buckets(ctx context.Context, projectID string) *BucketIterator 791 codeexamples: 792 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tit := client.Buckets(ctx, \"my-bucket\")\n\t_ = it // TODO: iterate using Next or iterator.Pager.\n}\n" 793- uid: cloud.google.com/go/storage.Client.Close 794 name: | 795 func (*Client) Close 796 id: Close 797 summary: | 798 Close closes the Client. 799 800 Close need not be called at program exit. 801 parent: cloud.google.com/go/storage.Client 802 type: function 803 langs: 804 - go 805 syntax: 806 content: func (c *Client) Close() error 807- uid: cloud.google.com/go/storage.Client.CreateHMACKey 808 name: | 809 func (*Client) CreateHMACKey 810 id: CreateHMACKey 811 summary: | 812 CreateHMACKey invokes an RPC for Google Cloud Storage to create a new HMACKey. 813 814 This method is EXPERIMENTAL and subject to change or removal without notice. 815 parent: cloud.google.com/go/storage.Client 816 type: function 817 langs: 818 - go 819 syntax: 820 content: func (c *Client) CreateHMACKey(ctx context.Context, projectID, serviceAccountEmail string, ...) (*HMACKey, error) 821 codeexamples: 822 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\n\thkey, err := client.CreateHMACKey(ctx, \"project-id\", \"service-account-email\")\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\t_ = hkey // TODO: Use the HMAC Key.\n}\n" 823- uid: cloud.google.com/go/storage.Client.HMACKeyHandle 824 name: | 825 func (*Client) HMACKeyHandle 826 id: HMACKeyHandle 827 summary: | 828 HMACKeyHandle creates a handle that will be used for HMACKey operations. 829 830 This method is EXPERIMENTAL and subject to change or removal without notice. 831 parent: cloud.google.com/go/storage.Client 832 type: function 833 langs: 834 - go 835 syntax: 836 content: func (c *Client) HMACKeyHandle(projectID, accessID string) *HMACKeyHandle 837- uid: cloud.google.com/go/storage.Client.ListHMACKeys 838 name: | 839 func (*Client) ListHMACKeys 840 id: ListHMACKeys 841 summary: | 842 ListHMACKeys returns an iterator for listing HMACKeys. 843 844 Note: This iterator is not safe for concurrent operations without explicit synchronization. 845 846 This method is EXPERIMENTAL and subject to change or removal without notice. 847 parent: cloud.google.com/go/storage.Client 848 type: function 849 langs: 850 - go 851 syntax: 852 content: func (c *Client) ListHMACKeys(ctx context.Context, projectID string, opts ...HMACKeyOption) *HMACKeysIterator 853 codeexamples: 854 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"google.golang.org/api/iterator\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\n\titer := client.ListHMACKeys(ctx, \"project-id\")\n\tfor {\n\t\tkey, err := iter.Next()\n\t\tif err == iterator.Done {\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\t// TODO: handle error.\n\t\t}\n\t\t_ = key // TODO: Use the key.\n\t}\n}\n" 855 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"google.golang.org/api/iterator\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\n\titer := client.ListHMACKeys(ctx, \"project-id\", storage.ForHMACKeyServiceAccountEmail(\"service@account.email\"))\n\tfor {\n\t\tkey, err := iter.Next()\n\t\tif err == iterator.Done {\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\t// TODO: handle error.\n\t\t}\n\t\t_ = key // TODO: Use the key.\n\t}\n}\n" 856 name: forServiceAccountEmail 857 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"google.golang.org/api/iterator\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\n\titer := client.ListHMACKeys(ctx, \"project-id\", storage.ShowDeletedHMACKeys())\n\tfor {\n\t\tkey, err := iter.Next()\n\t\tif err == iterator.Done {\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\t// TODO: handle error.\n\t\t}\n\t\t_ = key // TODO: Use the key.\n\t}\n}\n" 858 name: showDeletedKeys 859- uid: cloud.google.com/go/storage.Client.ServiceAccount 860 name: | 861 func (*Client) ServiceAccount 862 id: ServiceAccount 863 summary: | 864 ServiceAccount fetches the email address of the given project's Google Cloud Storage service account. 865 parent: cloud.google.com/go/storage.Client 866 type: function 867 langs: 868 - go 869 syntax: 870 content: func (c *Client) ServiceAccount(ctx context.Context, projectID string) (string, error) 871- uid: cloud.google.com/go/storage.Composer 872 name: Composer 873 id: Composer 874 summary: | 875 A Composer composes source objects into a destination object. 876 877 For Requester Pays buckets, the user project of dst is billed. 878 parent: cloud.google.com/go/storage 879 type: type 880 langs: 881 - go 882 syntax: 883 content: "type Composer struct {\n\t// ObjectAttrs are optional attributes to set on the destination object.\n\t// Any attributes must be initialized before any calls on the Composer. Nil\n\t// or zero-valued attributes are ignored.\n\tObjectAttrs\n\n\t// SendCRC specifies whether to transmit a CRC32C field. It should be set\n\t// to true in addition to setting the Composer's CRC32C field, because zero\n\t// is a valid CRC and normally a zero would not be transmitted.\n\t// If a CRC32C is sent, and the data in the destination object does not match\n\t// the checksum, the compose will be rejected.\n\tSendCRC32C bool\n\t// contains filtered or unexported fields\n}" 884- uid: cloud.google.com/go/storage.Composer.Run 885 name: | 886 func (*Composer) Run 887 id: Run 888 summary: | 889 Run performs the compose operation. 890 parent: cloud.google.com/go/storage.Composer 891 type: function 892 langs: 893 - go 894 syntax: 895 content: func (c *Composer) Run(ctx context.Context) (attrs *ObjectAttrs, err error) 896 codeexamples: 897 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tbkt := client.Bucket(\"bucketname\")\n\tsrc1 := bkt.Object(\"o1\")\n\tsrc2 := bkt.Object(\"o2\")\n\tdst := bkt.Object(\"o3\")\n\n\t// Compose and modify metadata.\n\tc := dst.ComposerFrom(src1, src2)\n\tc.ContentType = \"text/plain\"\n\n\t// Set the expected checksum for the destination object to be validated by\n\t// the backend (if desired).\n\tc.CRC32C = 42\n\tc.SendCRC32C = true\n\n\tattrs, err := c.Run(ctx)\n\tif err != nil {\n\t\t// TODO: Handle error.\n\t}\n\tfmt.Println(attrs)\n\t// Just compose.\n\tattrs, err = dst.ComposerFrom(src1, src2).Run(ctx)\n\tif err != nil {\n\t\t// TODO: Handle error.\n\t}\n\tfmt.Println(attrs)\n}\n" 898- uid: cloud.google.com/go/storage.Conditions 899 name: Conditions 900 id: Conditions 901 summary: | 902 Conditions constrain methods to act on specific generations of 903 objects. 904 905 The zero value is an empty set of constraints. Not all conditions or 906 combinations of conditions are applicable to all methods. 907 See https://cloud.google.com/storage/docs/generations-preconditions 908 for details on how these operate. 909 parent: cloud.google.com/go/storage 910 type: type 911 langs: 912 - go 913 syntax: 914 content: "type Conditions struct {\n\n\t// GenerationMatch specifies that the object must have the given generation\n\t// for the operation to occur.\n\t// If GenerationMatch is zero, it has no effect.\n\t// Use DoesNotExist to specify that the object does not exist in the bucket.\n\tGenerationMatch int64\n\n\t// GenerationNotMatch specifies that the object must not have the given\n\t// generation for the operation to occur.\n\t// If GenerationNotMatch is zero, it has no effect.\n\tGenerationNotMatch int64\n\n\t// DoesNotExist specifies that the object must not exist in the bucket for\n\t// the operation to occur.\n\t// If DoesNotExist is false, it has no effect.\n\tDoesNotExist bool\n\n\t// MetagenerationMatch specifies that the object must have the given\n\t// metageneration for the operation to occur.\n\t// If MetagenerationMatch is zero, it has no effect.\n\tMetagenerationMatch int64\n\n\t// MetagenerationNotMatch specifies that the object must not have the given\n\t// metageneration for the operation to occur.\n\t// If MetagenerationNotMatch is zero, it has no effect.\n\tMetagenerationNotMatch int64\n}" 915- uid: cloud.google.com/go/storage.Copier 916 name: Copier 917 id: Copier 918 summary: | 919 A Copier copies a source object to a destination. 920 parent: cloud.google.com/go/storage 921 type: type 922 langs: 923 - go 924 syntax: 925 content: "type Copier struct {\n\t// ObjectAttrs are optional attributes to set on the destination object.\n\t// Any attributes must be initialized before any calls on the Copier. Nil\n\t// or zero-valued attributes are ignored.\n\tObjectAttrs\n\n\t// RewriteToken can be set before calling Run to resume a copy\n\t// operation. After Run returns a non-nil error, RewriteToken will\n\t// have been updated to contain the value needed to resume the copy.\n\tRewriteToken string\n\n\t// ProgressFunc can be used to monitor the progress of a multi-RPC copy\n\t// operation. If ProgressFunc is not nil and copying requires multiple\n\t// calls to the underlying service (see\n\t// https://cloud.google.com/storage/docs/json_api/v1/objects/rewrite), then\n\t// ProgressFunc will be invoked after each call with the number of bytes of\n\t// content copied so far and the total size in bytes of the source object.\n\t//\n\t// ProgressFunc is intended to make upload progress available to the\n\t// application. For example, the implementation of ProgressFunc may update\n\t// a progress bar in the application's UI, or log the result of\n\t// float64(copiedBytes)/float64(totalBytes).\n\t//\n\t// ProgressFunc should return quickly without blocking.\n\tProgressFunc func(copiedBytes, totalBytes uint64)\n\n\t// The Cloud KMS key, in the form projects/P/locations/L/keyRings/R/cryptoKeys/K,\n\t// that will be used to encrypt the object. Overrides the object's KMSKeyName, if\n\t// any.\n\t//\n\t// Providing both a DestinationKMSKeyName and a customer-supplied encryption key\n\t// (via ObjectHandle.Key) on the destination object will result in an error when\n\t// Run is called.\n\tDestinationKMSKeyName string\n\t// contains filtered or unexported fields\n}" 926- uid: cloud.google.com/go/storage.Copier.Run 927 name: | 928 func (*Copier) Run 929 id: Run 930 summary: | 931 Run performs the copy. 932 parent: cloud.google.com/go/storage.Copier 933 type: function 934 langs: 935 - go 936 syntax: 937 content: func (c *Copier) Run(ctx context.Context) (attrs *ObjectAttrs, err error) 938 codeexamples: 939 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tsrc := client.Bucket(\"bucketname\").Object(\"file1\")\n\tdst := client.Bucket(\"another-bucketname\").Object(\"file2\")\n\n\t// Copy content and modify metadata.\n\tcopier := dst.CopierFrom(src)\n\tcopier.ContentType = \"text/plain\"\n\tattrs, err := copier.Run(ctx)\n\tif err != nil {\n\t\t// TODO: Handle error, possibly resuming with copier.RewriteToken.\n\t}\n\tfmt.Println(attrs)\n\n\t// Just copy content.\n\tattrs, err = dst.CopierFrom(src).Run(ctx)\n\tif err != nil {\n\t\t// TODO: Handle error. No way to resume.\n\t}\n\tfmt.Println(attrs)\n}\n" 940 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n\t// Display progress across multiple rewrite RPCs.\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tsrc := client.Bucket(\"bucketname\").Object(\"file1\")\n\tdst := client.Bucket(\"another-bucketname\").Object(\"file2\")\n\n\tcopier := dst.CopierFrom(src)\n\tcopier.ProgressFunc = func(copiedBytes, totalBytes uint64) {\n\t\tlog.Printf(\"copy %.1f%% done\", float64(copiedBytes)/float64(totalBytes)*100)\n\t}\n\tif _, err := copier.Run(ctx); err != nil {\n\t\t// TODO: handle error.\n\t}\n}\n" 941 name: progress 942- uid: cloud.google.com/go/storage.HMACKey 943 name: HMACKey 944 id: HMACKey 945 summary: | 946 HMACKey is the representation of a Google Cloud Storage HMAC key. 947 948 HMAC keys are used to authenticate signed access to objects. To enable HMAC key 949 authentication, please visit https://cloud.google.com/storage/docs/migrating. 950 951 This type is EXPERIMENTAL and subject to change or removal without notice. 952 parent: cloud.google.com/go/storage 953 type: type 954 langs: 955 - go 956 syntax: 957 content: "type HMACKey struct {\n\t// The HMAC's secret key.\n\tSecret string\n\n\t// AccessID is the ID of the HMAC key.\n\tAccessID string\n\n\t// Etag is the HTTP/1.1 Entity tag.\n\tEtag string\n\n\t// ID is the ID of the HMAC key, including the ProjectID and AccessID.\n\tID string\n\n\t// ProjectID is the ID of the project that owns the\n\t// service account to which the key authenticates.\n\tProjectID string\n\n\t// ServiceAccountEmail is the email address\n\t// of the key's associated service account.\n\tServiceAccountEmail string\n\n\t// CreatedTime is the creation time of the HMAC key.\n\tCreatedTime time.Time\n\n\t// UpdatedTime is the last modification time of the HMAC key metadata.\n\tUpdatedTime time.Time\n\n\t// State is the state of the HMAC key.\n\t// It can be one of StateActive, StateInactive or StateDeleted.\n\tState HMACState\n}" 958- uid: cloud.google.com/go/storage.HMACKeyAttrsToUpdate 959 name: HMACKeyAttrsToUpdate 960 id: HMACKeyAttrsToUpdate 961 summary: | 962 HMACKeyAttrsToUpdate defines the attributes of an HMACKey that will be updated. 963 964 This type is EXPERIMENTAL and subject to change or removal without notice. 965 parent: cloud.google.com/go/storage 966 type: type 967 langs: 968 - go 969 syntax: 970 content: "type HMACKeyAttrsToUpdate struct {\n\t// State is required and must be either StateActive or StateInactive.\n\tState HMACState\n\n\t// Etag is an optional field and it is the HTTP/1.1 Entity tag.\n\tEtag string\n}" 971- uid: cloud.google.com/go/storage.HMACKeyHandle 972 name: HMACKeyHandle 973 id: HMACKeyHandle 974 summary: | 975 HMACKeyHandle helps provide access and management for HMAC keys. 976 977 This type is EXPERIMENTAL and subject to change or removal without notice. 978 parent: cloud.google.com/go/storage 979 type: type 980 langs: 981 - go 982 syntax: 983 content: "type HMACKeyHandle struct {\n\t// contains filtered or unexported fields\n}" 984- uid: cloud.google.com/go/storage.HMACKeyHandle.Delete 985 name: | 986 func (*HMACKeyHandle) Delete 987 id: Delete 988 summary: | 989 Delete invokes an RPC to delete the key referenced by accessID, on Google Cloud Storage. 990 Only inactive HMAC keys can be deleted. 991 After deletion, a key cannot be used to authenticate requests. 992 993 This method is EXPERIMENTAL and subject to change or removal without notice. 994 parent: cloud.google.com/go/storage.HMACKeyHandle 995 type: function 996 langs: 997 - go 998 syntax: 999 content: func (hkh *HMACKeyHandle) Delete(ctx context.Context, opts ...HMACKeyOption) error 1000 codeexamples: 1001 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\n\thkh := client.HMACKeyHandle(\"project-id\", \"access-key-id\")\n\t// Make sure that the HMACKey being deleted has a status of inactive.\n\tif err := hkh.Delete(ctx); err != nil {\n\t\t// TODO: handle error.\n\t}\n}\n" 1002- uid: cloud.google.com/go/storage.HMACKeyHandle.Get 1003 name: | 1004 func (*HMACKeyHandle) Get 1005 id: Get 1006 summary: | 1007 Get invokes an RPC to retrieve the HMAC key referenced by the 1008 HMACKeyHandle's accessID. 1009 1010 Options such as UserProjectForHMACKeys can be used to set the 1011 userProject to be billed against for operations. 1012 1013 This method is EXPERIMENTAL and subject to change or removal without notice. 1014 parent: cloud.google.com/go/storage.HMACKeyHandle 1015 type: function 1016 langs: 1017 - go 1018 syntax: 1019 content: func (hkh *HMACKeyHandle) Get(ctx context.Context, opts ...HMACKeyOption) (*HMACKey, error) 1020 codeexamples: 1021 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\n\thkh := client.HMACKeyHandle(\"project-id\", \"access-key-id\")\n\thkey, err := hkh.Get(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\t_ = hkey // TODO: Use the HMAC Key.\n}\n" 1022- uid: cloud.google.com/go/storage.HMACKeyHandle.Update 1023 name: | 1024 func (*HMACKeyHandle) Update 1025 id: Update 1026 summary: | 1027 Update mutates the HMACKey referred to by accessID. 1028 1029 This method is EXPERIMENTAL and subject to change or removal without notice. 1030 parent: cloud.google.com/go/storage.HMACKeyHandle 1031 type: function 1032 langs: 1033 - go 1034 syntax: 1035 content: func (h *HMACKeyHandle) Update(ctx context.Context, au HMACKeyAttrsToUpdate, opts ...HMACKeyOption) (*HMACKey, error) 1036 codeexamples: 1037 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\n\thkh := client.HMACKeyHandle(\"project-id\", \"access-key-id\")\n\tukey, err := hkh.Update(ctx, storage.HMACKeyAttrsToUpdate{\n\t\tState: storage.Inactive,\n\t})\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\t_ = ukey // TODO: Use the HMAC Key.\n}\n" 1038- uid: cloud.google.com/go/storage.HMACKeyOption 1039 name: HMACKeyOption 1040 id: HMACKeyOption 1041 summary: | 1042 HMACKeyOption configures the behavior of HMACKey related methods and actions. 1043 1044 This interface is EXPERIMENTAL and subject to change or removal without notice. 1045 parent: cloud.google.com/go/storage 1046 type: type 1047 langs: 1048 - go 1049 syntax: 1050 content: "type HMACKeyOption interface {\n\t// contains filtered or unexported methods\n}" 1051- uid: cloud.google.com/go/storage.HMACKeyOption.ForHMACKeyServiceAccountEmail 1052 name: | 1053 func ForHMACKeyServiceAccountEmail 1054 id: ForHMACKeyServiceAccountEmail 1055 summary: | 1056 ForHMACKeyServiceAccountEmail returns HMAC Keys that are 1057 associated with the email address of a service account in the project. 1058 1059 Only one service account email can be used as a filter, so if multiple 1060 of these options are applied, the last email to be set will be used. 1061 1062 This option is EXPERIMENTAL and subject to change or removal without notice. 1063 parent: cloud.google.com/go/storage.HMACKeyOption 1064 type: function 1065 langs: 1066 - go 1067 syntax: 1068 content: func ForHMACKeyServiceAccountEmail(serviceAccountEmail string) HMACKeyOption 1069- uid: cloud.google.com/go/storage.HMACKeyOption.ShowDeletedHMACKeys 1070 name: | 1071 func ShowDeletedHMACKeys 1072 id: ShowDeletedHMACKeys 1073 summary: | 1074 ShowDeletedHMACKeys will also list keys whose state is "DELETED". 1075 1076 This option is EXPERIMENTAL and subject to change or removal without notice. 1077 parent: cloud.google.com/go/storage.HMACKeyOption 1078 type: function 1079 langs: 1080 - go 1081 syntax: 1082 content: func ShowDeletedHMACKeys() HMACKeyOption 1083- uid: cloud.google.com/go/storage.HMACKeyOption.UserProjectForHMACKeys 1084 name: | 1085 func UserProjectForHMACKeys 1086 id: UserProjectForHMACKeys 1087 summary: | 1088 UserProjectForHMACKeys will bill the request against userProjectID 1089 if userProjectID is non-empty. 1090 1091 Note: This is a noop right now and only provided for API compatibility. 1092 1093 This option is EXPERIMENTAL and subject to change or removal without notice. 1094 parent: cloud.google.com/go/storage.HMACKeyOption 1095 type: function 1096 langs: 1097 - go 1098 syntax: 1099 content: func UserProjectForHMACKeys(userProjectID string) HMACKeyOption 1100- uid: cloud.google.com/go/storage.HMACKeysIterator 1101 name: HMACKeysIterator 1102 id: HMACKeysIterator 1103 summary: | 1104 An HMACKeysIterator is an iterator over HMACKeys. 1105 1106 Note: This iterator is not safe for concurrent operations without explicit synchronization. 1107 1108 This type is EXPERIMENTAL and subject to change or removal without notice. 1109 parent: cloud.google.com/go/storage 1110 type: type 1111 langs: 1112 - go 1113 syntax: 1114 content: "type HMACKeysIterator struct {\n\t// contains filtered or unexported fields\n}" 1115- uid: cloud.google.com/go/storage.HMACKeysIterator.Next 1116 name: | 1117 func (*HMACKeysIterator) Next 1118 id: Next 1119 summary: | 1120 Next returns the next result. Its second return value is iterator.Done if 1121 there are no more results. Once Next returns iterator.Done, all subsequent 1122 calls will return iterator.Done. 1123 1124 Note: This iterator is not safe for concurrent operations without explicit synchronization. 1125 1126 This method is EXPERIMENTAL and subject to change or removal without notice. 1127 parent: cloud.google.com/go/storage.HMACKeysIterator 1128 type: function 1129 langs: 1130 - go 1131 syntax: 1132 content: func (it *HMACKeysIterator) Next() (*HMACKey, error) 1133- uid: cloud.google.com/go/storage.HMACKeysIterator.PageInfo 1134 name: | 1135 func (*HMACKeysIterator) PageInfo 1136 id: PageInfo 1137 summary: | 1138 PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1139 1140 Note: This iterator is not safe for concurrent operations without explicit synchronization. 1141 1142 This method is EXPERIMENTAL and subject to change or removal without notice. 1143 parent: cloud.google.com/go/storage.HMACKeysIterator 1144 type: function 1145 langs: 1146 - go 1147 syntax: 1148 content: func (it *HMACKeysIterator) PageInfo() *iterator.PageInfo 1149- uid: cloud.google.com/go/storage.HMACState 1150 name: HMACState 1151 id: HMACState 1152 summary: | 1153 HMACState is the state of the HMAC key. 1154 1155 This type is EXPERIMENTAL and subject to change or removal without notice. 1156 parent: cloud.google.com/go/storage 1157 type: type 1158 langs: 1159 - go 1160 syntax: 1161 content: type HMACState string 1162- uid: cloud.google.com/go/storage.Active,Inactive,Deleted 1163 name: Active, Inactive, Deleted 1164 id: Active,Inactive,Deleted 1165 parent: cloud.google.com/go/storage.HMACState 1166 type: const 1167 langs: 1168 - go 1169 syntax: 1170 content: "const (\n\t// Active is the status for an active key that can be used to sign\n\t// requests.\n\tActive HMACState = \"ACTIVE\"\n\n\t// Inactive is the status for an inactive key thus requests signed by\n\t// this key will be denied.\n\tInactive HMACState = \"INACTIVE\"\n\n\t// Deleted is the status for a key that is deleted.\n\t// Once in this state the key cannot key cannot be recovered\n\t// and does not count towards key limits. Deleted keys will be cleaned\n\t// up later.\n\tDeleted HMACState = \"DELETED\"\n)" 1171- uid: cloud.google.com/go/storage.Lifecycle 1172 name: Lifecycle 1173 id: Lifecycle 1174 summary: | 1175 Lifecycle is the lifecycle configuration for objects in the bucket. 1176 parent: cloud.google.com/go/storage 1177 type: type 1178 langs: 1179 - go 1180 syntax: 1181 content: "type Lifecycle struct {\n\tRules []LifecycleRule\n}" 1182- uid: cloud.google.com/go/storage.LifecycleAction 1183 name: LifecycleAction 1184 id: LifecycleAction 1185 summary: | 1186 LifecycleAction is a lifecycle configuration action. 1187 parent: cloud.google.com/go/storage 1188 type: type 1189 langs: 1190 - go 1191 syntax: 1192 content: "type LifecycleAction struct {\n\t// Type is the type of action to take on matching objects.\n\t//\n\t// Acceptable values are \"Delete\" to delete matching objects and\n\t// \"SetStorageClass\" to set the storage class defined in StorageClass on\n\t// matching objects.\n\tType string\n\n\t// StorageClass is the storage class to set on matching objects if the Action\n\t// is \"SetStorageClass\".\n\tStorageClass string\n}" 1193- uid: cloud.google.com/go/storage.LifecycleCondition 1194 name: LifecycleCondition 1195 id: LifecycleCondition 1196 summary: | 1197 LifecycleCondition is a set of conditions used to match objects and take an 1198 action automatically. 1199 1200 All configured conditions must be met for the associated action to be taken. 1201 parent: cloud.google.com/go/storage 1202 type: type 1203 langs: 1204 - go 1205 syntax: 1206 content: "type LifecycleCondition struct {\n\t// AgeInDays is the age of the object in days.\n\tAgeInDays int64\n\n\t// CreatedBefore is the time the object was created.\n\t//\n\t// This condition is satisfied when an object is created before midnight of\n\t// the specified date in UTC.\n\tCreatedBefore time.Time\n\n\t// CustomTimeBefore is the CustomTime metadata field of the object. This\n\t// condition is satisfied when an object's CustomTime timestamp is before\n\t// midnight of the specified date in UTC.\n\t//\n\t// This condition can only be satisfied if CustomTime has been set.\n\tCustomTimeBefore time.Time\n\n\t// DaysSinceCustomTime is the days elapsed since the CustomTime date of the\n\t// object. This condition can only be satisfied if CustomTime has been set.\n\tDaysSinceCustomTime int64\n\n\t// DaysSinceNoncurrentTime is the days elapsed since the noncurrent timestamp\n\t// of the object. This condition is relevant only for versioned objects.\n\tDaysSinceNoncurrentTime int64\n\n\t// Liveness specifies the object's liveness. Relevant only for versioned objects\n\tLiveness Liveness\n\n\t// MatchesStorageClasses is the condition matching the object's storage\n\t// class.\n\t//\n\t// Values include \"STANDARD\", \"NEARLINE\", \"COLDLINE\" and \"ARCHIVE\".\n\tMatchesStorageClasses []string\n\n\t// NoncurrentTimeBefore is the noncurrent timestamp of the object. This\n\t// condition is satisfied when an object's noncurrent timestamp is before\n\t// midnight of the specified date in UTC.\n\t//\n\t// This condition is relevant only for versioned objects.\n\tNoncurrentTimeBefore time.Time\n\n\t// NumNewerVersions is the condition matching objects with a number of newer versions.\n\t//\n\t// If the value is N, this condition is satisfied when there are at least N\n\t// versions (including the live version) newer than this version of the\n\t// object.\n\tNumNewerVersions int64\n}" 1207- uid: cloud.google.com/go/storage.LifecycleRule 1208 name: LifecycleRule 1209 id: LifecycleRule 1210 summary: | 1211 LifecycleRule is a lifecycle configuration rule. 1212 1213 When all the configured conditions are met by an object in the bucket, the 1214 configured action will automatically be taken on that object. 1215 parent: cloud.google.com/go/storage 1216 type: type 1217 langs: 1218 - go 1219 syntax: 1220 content: "type LifecycleRule struct {\n\t// Action is the action to take when all of the associated conditions are\n\t// met.\n\tAction LifecycleAction\n\n\t// Condition is the set of conditions that must be met for the associated\n\t// action to be taken.\n\tCondition LifecycleCondition\n}" 1221- uid: cloud.google.com/go/storage.Liveness 1222 name: Liveness 1223 id: Liveness 1224 summary: | 1225 Liveness specifies whether the object is live or not. 1226 parent: cloud.google.com/go/storage 1227 type: type 1228 langs: 1229 - go 1230 syntax: 1231 content: type Liveness int 1232- uid: cloud.google.com/go/storage.LiveAndArchived,Live,Archived 1233 name: LiveAndArchived, Live, Archived 1234 id: LiveAndArchived,Live,Archived 1235 parent: cloud.google.com/go/storage.Liveness 1236 type: const 1237 langs: 1238 - go 1239 syntax: 1240 content: "const (\n\t// LiveAndArchived includes both live and archived objects.\n\tLiveAndArchived Liveness = iota\n\t// Live specifies that the object is still live.\n\tLive\n\t// Archived specifies that the object is archived.\n\tArchived\n)" 1241- uid: cloud.google.com/go/storage.Notification 1242 name: Notification 1243 id: Notification 1244 summary: | 1245 A Notification describes how to send Cloud PubSub messages when certain 1246 events occur in a bucket. 1247 parent: cloud.google.com/go/storage 1248 type: type 1249 langs: 1250 - go 1251 syntax: 1252 content: "type Notification struct {\n\t//The ID of the notification.\n\tID string\n\n\t// The ID of the topic to which this subscription publishes.\n\tTopicID string\n\n\t// The ID of the project to which the topic belongs.\n\tTopicProjectID string\n\n\t// Only send notifications about listed event types. If empty, send notifications\n\t// for all event types.\n\t// See https://cloud.google.com/storage/docs/pubsub-notifications#events.\n\tEventTypes []string\n\n\t// If present, only apply this notification configuration to object names that\n\t// begin with this prefix.\n\tObjectNamePrefix string\n\n\t// An optional list of additional attributes to attach to each Cloud PubSub\n\t// message published for this notification subscription.\n\tCustomAttributes map[string]string\n\n\t// The contents of the message payload.\n\t// See https://cloud.google.com/storage/docs/pubsub-notifications#payload.\n\tPayloadFormat string\n}" 1253- uid: cloud.google.com/go/storage.ObjectAttrs 1254 name: ObjectAttrs 1255 id: ObjectAttrs 1256 summary: | 1257 ObjectAttrs represents the metadata for a Google Cloud Storage (GCS) object. 1258 parent: cloud.google.com/go/storage 1259 type: type 1260 langs: 1261 - go 1262 syntax: 1263 content: "type ObjectAttrs struct {\n\t// Bucket is the name of the bucket containing this GCS object.\n\t// This field is read-only.\n\tBucket string\n\n\t// Name is the name of the object within the bucket.\n\t// This field is read-only.\n\tName string\n\n\t// ContentType is the MIME type of the object's content.\n\tContentType string\n\n\t// ContentLanguage is the content language of the object's content.\n\tContentLanguage string\n\n\t// CacheControl is the Cache-Control header to be sent in the response\n\t// headers when serving the object data.\n\tCacheControl string\n\n\t// EventBasedHold specifies whether an object is under event-based hold. New\n\t// objects created in a bucket whose DefaultEventBasedHold is set will\n\t// default to that value.\n\tEventBasedHold bool\n\n\t// TemporaryHold specifies whether an object is under temporary hold. While\n\t// this flag is set to true, the object is protected against deletion and\n\t// overwrites.\n\tTemporaryHold bool\n\n\t// RetentionExpirationTime is a server-determined value that specifies the\n\t// earliest time that the object's retention period expires.\n\t// This is a read-only field.\n\tRetentionExpirationTime time.Time\n\n\t// ACL is the list of access control rules for the object.\n\tACL []ACLRule\n\n\t// If not empty, applies a predefined set of access controls. It should be set\n\t// only when writing, copying or composing an object. When copying or composing,\n\t// it acts as the destinationPredefinedAcl parameter.\n\t// PredefinedACL is always empty for ObjectAttrs returned from the service.\n\t// See https://cloud.google.com/storage/docs/json_api/v1/objects/insert\n\t// for valid values.\n\tPredefinedACL string\n\n\t// Owner is the owner of the object. This field is read-only.\n\t//\n\t// If non-zero, it is in the form of \"user-<userId>\".\n\tOwner string\n\n\t// Size is the length of the object's content. This field is read-only.\n\tSize int64\n\n\t// ContentEncoding is the encoding of the object's content.\n\tContentEncoding string\n\n\t// ContentDisposition is the optional Content-Disposition header of the object\n\t// sent in the response headers.\n\tContentDisposition string\n\n\t// MD5 is the MD5 hash of the object's content. This field is read-only,\n\t// except when used from a Writer. If set on a Writer, the uploaded\n\t// data is rejected if its MD5 hash does not match this field.\n\tMD5 []byte\n\n\t// CRC32C is the CRC32 checksum of the object's content using the Castagnoli93\n\t// polynomial. This field is read-only, except when used from a Writer or\n\t// Composer. In those cases, if the SendCRC32C field in the Writer or Composer\n\t// is set to is true, the uploaded data is rejected if its CRC32C hash does\n\t// not match this field.\n\tCRC32C uint32\n\n\t// MediaLink is an URL to the object's content. This field is read-only.\n\tMediaLink string\n\n\t// Metadata represents user-provided metadata, in key/value pairs.\n\t// It can be nil if no metadata is provided.\n\tMetadata map[string]string\n\n\t// Generation is the generation number of the object's content.\n\t// This field is read-only.\n\tGeneration int64\n\n\t// Metageneration is the version of the metadata for this\n\t// object at this generation. This field is used for preconditions\n\t// and for detecting changes in metadata. A metageneration number\n\t// is only meaningful in the context of a particular generation\n\t// of a particular object. This field is read-only.\n\tMetageneration int64\n\n\t// StorageClass is the storage class of the object. This defines\n\t// how objects are stored and determines the SLA and the cost of storage.\n\t// Typical values are \"STANDARD\", \"NEARLINE\", \"COLDLINE\" and \"ARCHIVE\".\n\t// Defaults to \"STANDARD\".\n\t// See https://cloud.google.com/storage/docs/storage-classes for all\n\t// valid values.\n\tStorageClass string\n\n\t// Created is the time the object was created. This field is read-only.\n\tCreated time.Time\n\n\t// Deleted is the time the object was deleted.\n\t// If not deleted, it is the zero value. This field is read-only.\n\tDeleted time.Time\n\n\t// Updated is the creation or modification time of the object.\n\t// For buckets with versioning enabled, changing an object's\n\t// metadata does not change this property. This field is read-only.\n\tUpdated time.Time\n\n\t// CustomerKeySHA256 is the base64-encoded SHA-256 hash of the\n\t// customer-supplied encryption key for the object. It is empty if there is\n\t// no customer-supplied encryption key.\n\t// See // https://cloud.google.com/storage/docs/encryption for more about\n\t// encryption in Google Cloud Storage.\n\tCustomerKeySHA256 string\n\n\t// Cloud KMS key name, in the form\n\t// projects/P/locations/L/keyRings/R/cryptoKeys/K, used to encrypt this object,\n\t// if the object is encrypted by such a key.\n\t//\n\t// Providing both a KMSKeyName and a customer-supplied encryption key (via\n\t// ObjectHandle.Key) will result in an error when writing an object.\n\tKMSKeyName string\n\n\t// Prefix is set only for ObjectAttrs which represent synthetic \"directory\n\t// entries\" when iterating over buckets using Query.Delimiter. See\n\t// ObjectIterator.Next. When set, no other fields in ObjectAttrs will be\n\t// populated.\n\tPrefix string\n\n\t// Etag is the HTTP/1.1 Entity tag for the object.\n\t// This field is read-only.\n\tEtag string\n\n\t// A user-specified timestamp which can be applied to an object. This is\n\t// typically set in order to use the CustomTimeBefore and DaysSinceCustomTime\n\t// LifecycleConditions to manage object lifecycles.\n\t//\n\t// CustomTime cannot be removed once set on an object. It can be updated to a\n\t// later value but not to an earlier one.\n\tCustomTime time.Time\n}" 1264- uid: cloud.google.com/go/storage.ObjectAttrsToUpdate 1265 name: ObjectAttrsToUpdate 1266 id: ObjectAttrsToUpdate 1267 summary: | 1268 ObjectAttrsToUpdate is used to update the attributes of an object. 1269 Only fields set to non-nil values will be updated. 1270 Set a field to its zero value to delete it. 1271 1272 For example, to change ContentType and delete ContentEncoding and 1273 Metadata, use 1274 ObjectAttrsToUpdate{ 1275 ContentType: "text/html", 1276 ContentEncoding: "", 1277 Metadata: map[string]string{}, 1278 } 1279 parent: cloud.google.com/go/storage 1280 type: type 1281 langs: 1282 - go 1283 syntax: 1284 content: "type ObjectAttrsToUpdate struct {\n\tEventBasedHold optional.Bool\n\tTemporaryHold optional.Bool\n\tContentType optional.String\n\tContentLanguage optional.String\n\tContentEncoding optional.String\n\tContentDisposition optional.String\n\tCacheControl optional.String\n\tCustomTime time.Time\n\tMetadata map[string]string // set to map[string]string{} to delete\n\tACL []ACLRule\n\n\t// If not empty, applies a predefined set of access controls. ACL must be nil.\n\t// See https://cloud.google.com/storage/docs/json_api/v1/objects/patch.\n\tPredefinedACL string\n}" 1285- uid: cloud.google.com/go/storage.ObjectHandle 1286 name: ObjectHandle 1287 id: ObjectHandle 1288 summary: | 1289 ObjectHandle provides operations on an object in a Google Cloud Storage bucket. 1290 Use BucketHandle.Object to get a handle. 1291 parent: cloud.google.com/go/storage 1292 type: type 1293 langs: 1294 - go 1295 syntax: 1296 content: "type ObjectHandle struct {\n\t// contains filtered or unexported fields\n}" 1297 codeexamples: 1298 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\n\tattrs, err := client.Bucket(\"my-bucket\").Object(\"my-object\").Attrs(ctx)\n\tif err == storage.ErrObjectNotExist {\n\t\tfmt.Println(\"The object does not exist\")\n\t\treturn\n\t}\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Printf(\"The object exists and has attributes: %#v\\n\", attrs)\n}\n" 1299 name: exists 1300- uid: cloud.google.com/go/storage.ObjectHandle.ACL 1301 name: | 1302 func (*ObjectHandle) ACL 1303 id: ACL 1304 summary: | 1305 ACL provides access to the object's access control list. 1306 This controls who can read and write this object. 1307 This call does not perform any network operations. 1308 parent: cloud.google.com/go/storage.ObjectHandle 1309 type: function 1310 langs: 1311 - go 1312 syntax: 1313 content: func (o *ObjectHandle) ACL() *ACLHandle 1314- uid: cloud.google.com/go/storage.ObjectHandle.Attrs 1315 name: | 1316 func (*ObjectHandle) Attrs 1317 id: Attrs 1318 summary: | 1319 Attrs returns meta information about the object. 1320 ErrObjectNotExist will be returned if the object is not found. 1321 parent: cloud.google.com/go/storage.ObjectHandle 1322 type: function 1323 langs: 1324 - go 1325 syntax: 1326 content: func (o *ObjectHandle) Attrs(ctx context.Context) (attrs *ObjectAttrs, err error) 1327 codeexamples: 1328 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tobjAttrs, err := client.Bucket(\"my-bucket\").Object(\"my-object\").Attrs(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Println(objAttrs)\n}\n" 1329 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tobj := client.Bucket(\"my-bucket\").Object(\"my-object\")\n\t// Read the object.\n\tobjAttrs1, err := obj.Attrs(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\t// Do something else for a while.\n\ttime.Sleep(5 * time.Minute)\n\t// Now read the same contents, even if the object has been written since the last read.\n\tobjAttrs2, err := obj.Generation(objAttrs1.Generation).Attrs(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Println(objAttrs1, objAttrs2)\n}\n" 1330 name: withConditions 1331- uid: cloud.google.com/go/storage.ObjectHandle.BucketName 1332 name: | 1333 func (*ObjectHandle) BucketName 1334 id: BucketName 1335 summary: | 1336 BucketName returns the name of the bucket. 1337 parent: cloud.google.com/go/storage.ObjectHandle 1338 type: function 1339 langs: 1340 - go 1341 syntax: 1342 content: func (o *ObjectHandle) BucketName() string 1343- uid: cloud.google.com/go/storage.ObjectHandle.ComposerFrom 1344 name: | 1345 func (*ObjectHandle) ComposerFrom 1346 id: ComposerFrom 1347 summary: | 1348 ComposerFrom creates a Composer that can compose srcs into dst. 1349 You can immediately call Run on the returned Composer, or you can 1350 configure it first. 1351 1352 The encryption key for the destination object will be used to decrypt all 1353 source objects and encrypt the destination object. It is an error 1354 to specify an encryption key for any of the source objects. 1355 parent: cloud.google.com/go/storage.ObjectHandle 1356 type: function 1357 langs: 1358 - go 1359 syntax: 1360 content: func (dst *ObjectHandle) ComposerFrom(srcs ...*ObjectHandle) *Composer 1361- uid: cloud.google.com/go/storage.ObjectHandle.CopierFrom 1362 name: | 1363 func (*ObjectHandle) CopierFrom 1364 id: CopierFrom 1365 summary: | 1366 CopierFrom creates a Copier that can copy src to dst. 1367 You can immediately call Run on the returned Copier, or 1368 you can configure it first. 1369 1370 For Requester Pays buckets, the user project of dst is billed, unless it is empty, 1371 in which case the user project of src is billed. 1372 parent: cloud.google.com/go/storage.ObjectHandle 1373 type: function 1374 langs: 1375 - go 1376 syntax: 1377 content: func (dst *ObjectHandle) CopierFrom(src *ObjectHandle) *Copier 1378 codeexamples: 1379 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nvar key1, key2 []byte\n\nfunc main() {\n\t// To rotate the encryption key on an object, copy it onto itself.\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tobj := client.Bucket(\"bucketname\").Object(\"obj\")\n\t// Assume obj is encrypted with key1, and we want to change to key2.\n\t_, err = obj.Key(key2).CopierFrom(obj.Key(key1)).Run(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n}\n" 1380 name: rotateEncryptionKeys 1381- uid: cloud.google.com/go/storage.ObjectHandle.Delete 1382 name: | 1383 func (*ObjectHandle) Delete 1384 id: Delete 1385 summary: | 1386 Delete deletes the single specified object. 1387 parent: cloud.google.com/go/storage.ObjectHandle 1388 type: function 1389 langs: 1390 - go 1391 syntax: 1392 content: func (o *ObjectHandle) Delete(ctx context.Context) error 1393 codeexamples: 1394 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n\t\"google.golang.org/api/iterator\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\t// To delete multiple objects in a bucket, list them with an\n\t// ObjectIterator, then Delete them.\n\n\t// If you are using this package on the App Engine Flex runtime,\n\t// you can init a bucket client with your app's default bucket name.\n\t// See http://godoc.org/google.golang.org/appengine/file#DefaultBucketName.\n\tbucket := client.Bucket(\"my-bucket\")\n\tit := bucket.Objects(ctx, nil)\n\tfor {\n\t\tobjAttrs, err := it.Next()\n\t\tif err != nil && err != iterator.Done {\n\t\t\t// TODO: Handle error.\n\t\t}\n\t\tif err == iterator.Done {\n\t\t\tbreak\n\t\t}\n\t\tif err := bucket.Object(objAttrs.Name).Delete(ctx); err != nil {\n\t\t\t// TODO: Handle error.\n\t\t}\n\t}\n\tfmt.Println(\"deleted all object items in the bucket specified.\")\n}\n" 1395- uid: cloud.google.com/go/storage.ObjectHandle.Generation 1396 name: | 1397 func (*ObjectHandle) Generation 1398 id: Generation 1399 summary: | 1400 Generation returns a new ObjectHandle that operates on a specific generation 1401 of the object. 1402 By default, the handle operates on the latest generation. Not 1403 all operations work when given a specific generation; check the API 1404 endpoints at https://cloud.google.com/storage/docs/json_api/ for details. 1405 parent: cloud.google.com/go/storage.ObjectHandle 1406 type: function 1407 langs: 1408 - go 1409 syntax: 1410 content: func (o *ObjectHandle) Generation(gen int64) *ObjectHandle 1411 codeexamples: 1412 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"io\"\n\t\"os\"\n)\n\nvar gen int64\n\nfunc main() {\n\t// Read an object's contents from generation gen, regardless of the\n\t// current generation of the object.\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tobj := client.Bucket(\"my-bucket\").Object(\"my-object\")\n\trc, err := obj.Generation(gen).NewReader(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tdefer rc.Close()\n\tif _, err := io.Copy(os.Stdout, rc); err != nil {\n\t\t// TODO: handle error.\n\t}\n}\n" 1413- uid: cloud.google.com/go/storage.ObjectHandle.If 1414 name: | 1415 func (*ObjectHandle) If 1416 id: If 1417 summary: | 1418 If returns a new ObjectHandle that applies a set of preconditions. 1419 Preconditions already set on the ObjectHandle are ignored. 1420 Operations on the new handle will return an error if the preconditions are not 1421 satisfied. See https://cloud.google.com/storage/docs/generations-preconditions 1422 for more details. 1423 parent: cloud.google.com/go/storage.ObjectHandle 1424 type: function 1425 langs: 1426 - go 1427 syntax: 1428 content: func (o *ObjectHandle) If(conds Conditions) *ObjectHandle 1429 codeexamples: 1430 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"google.golang.org/api/googleapi\"\n\t\"io\"\n\t\"net/http\"\n\t\"os\"\n)\n\nvar gen int64\n\nfunc main() {\n\t// Read from an object only if the current generation is gen.\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tobj := client.Bucket(\"my-bucket\").Object(\"my-object\")\n\trc, err := obj.If(storage.Conditions{GenerationMatch: gen}).NewReader(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\n\tif _, err := io.Copy(os.Stdout, rc); err != nil {\n\t\t// TODO: handle error.\n\t}\n\tif err := rc.Close(); err != nil {\n\t\tswitch ee := err.(type) {\n\t\tcase *googleapi.Error:\n\t\t\tif ee.Code == http.StatusPreconditionFailed {\n\t\t\t\t// The condition presented in the If failed.\n\t\t\t\t// TODO: handle error.\n\t\t\t}\n\n\t\t\t// TODO: handle other status codes here.\n\n\t\tdefault:\n\t\t\t// TODO: handle error.\n\t\t}\n\t}\n}\n" 1431- uid: cloud.google.com/go/storage.ObjectHandle.Key 1432 name: | 1433 func (*ObjectHandle) Key 1434 id: Key 1435 summary: | 1436 Key returns a new ObjectHandle that uses the supplied encryption 1437 key to encrypt and decrypt the object's contents. 1438 1439 Encryption key must be a 32-byte AES-256 key. 1440 See https://cloud.google.com/storage/docs/encryption for details. 1441 parent: cloud.google.com/go/storage.ObjectHandle 1442 type: function 1443 langs: 1444 - go 1445 syntax: 1446 content: func (o *ObjectHandle) Key(encryptionKey []byte) *ObjectHandle 1447 codeexamples: 1448 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nvar secretKey []byte\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tobj := client.Bucket(\"my-bucket\").Object(\"my-object\")\n\t// Encrypt the object's contents.\n\tw := obj.Key(secretKey).NewWriter(ctx)\n\tif _, err := w.Write([]byte(\"top secret\")); err != nil {\n\t\t// TODO: handle error.\n\t}\n\tif err := w.Close(); err != nil {\n\t\t// TODO: handle error.\n\t}\n}\n" 1449- uid: cloud.google.com/go/storage.ObjectHandle.NewRangeReader 1450 name: | 1451 func (*ObjectHandle) NewRangeReader 1452 id: NewRangeReader 1453 summary: | 1454 NewRangeReader reads part of an object, reading at most length bytes 1455 starting at the given offset. If length is negative, the object is read 1456 until the end. If offset is negative, the object is read abs(offset) bytes 1457 from the end, and length must also be negative to indicate all remaining 1458 bytes will be read. 1459 1460 If the object's metadata property "Content-Encoding" is set to "gzip" or satisfies 1461 decompressive transcoding per https://cloud.google.com/storage/docs/transcoding 1462 that file will be served back whole, regardless of the requested range as 1463 Google Cloud Storage dictates. 1464 parent: cloud.google.com/go/storage.ObjectHandle 1465 type: function 1466 langs: 1467 - go 1468 syntax: 1469 content: func (o *ObjectHandle) NewRangeReader(ctx context.Context, offset, length int64) (r *Reader, err error) 1470 codeexamples: 1471 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\t// Read only the first 64K.\n\trc, err := client.Bucket(\"bucketname\").Object(\"filename1\").NewRangeReader(ctx, 0, 64*1024)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tdefer rc.Close()\n\n\tslurp, err := ioutil.ReadAll(rc)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Printf(\"first 64K of file contents:\\n%s\\n\", slurp)\n}\n" 1472 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\t// Read only the last 10 bytes until the end of the file.\n\trc, err := client.Bucket(\"bucketname\").Object(\"filename1\").NewRangeReader(ctx, -10, -1)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tdefer rc.Close()\n\n\tslurp, err := ioutil.ReadAll(rc)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Printf(\"Last 10 bytes from the end of the file:\\n%s\\n\", slurp)\n}\n" 1473 name: lastNBytes 1474 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\t// Read from the 101st byte until the end of the file.\n\trc, err := client.Bucket(\"bucketname\").Object(\"filename1\").NewRangeReader(ctx, 100, -1)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tdefer rc.Close()\n\n\tslurp, err := ioutil.ReadAll(rc)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Printf(\"From 101st byte until the end:\\n%s\\n\", slurp)\n}\n" 1475 name: untilEnd 1476- uid: cloud.google.com/go/storage.ObjectHandle.NewReader 1477 name: | 1478 func (*ObjectHandle) NewReader 1479 id: NewReader 1480 summary: | 1481 NewReader creates a new Reader to read the contents of the 1482 object. 1483 ErrObjectNotExist will be returned if the object is not found. 1484 1485 The caller must call Close on the returned Reader when done reading. 1486 parent: cloud.google.com/go/storage.ObjectHandle 1487 type: function 1488 langs: 1489 - go 1490 syntax: 1491 content: func (o *ObjectHandle) NewReader(ctx context.Context) (*Reader, error) 1492 codeexamples: 1493 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\trc, err := client.Bucket(\"my-bucket\").Object(\"my-object\").NewReader(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tslurp, err := ioutil.ReadAll(rc)\n\trc.Close()\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Println(\"file contents:\", slurp)\n}\n" 1494- uid: cloud.google.com/go/storage.ObjectHandle.NewWriter 1495 name: | 1496 func (*ObjectHandle) NewWriter 1497 id: NewWriter 1498 summary: | 1499 NewWriter returns a storage Writer that writes to the GCS object 1500 associated with this ObjectHandle. 1501 1502 A new object will be created unless an object with this name already exists. 1503 Otherwise any previous object with the same name will be replaced. 1504 The object will not be available (and any previous object will remain) 1505 until Close has been called. 1506 1507 Attributes can be set on the object by modifying the returned Writer's 1508 ObjectAttrs field before the first call to Write. If no ContentType 1509 attribute is specified, the content type will be automatically sniffed 1510 using net/http.DetectContentType. 1511 1512 It is the caller's responsibility to call Close when writing is done. To 1513 stop writing without saving the data, cancel the context. 1514 parent: cloud.google.com/go/storage.ObjectHandle 1515 type: function 1516 langs: 1517 - go 1518 syntax: 1519 content: func (o *ObjectHandle) NewWriter(ctx context.Context) *Writer 1520 codeexamples: 1521 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\twc := client.Bucket(\"bucketname\").Object(\"filename1\").NewWriter(ctx)\n\t_ = wc // TODO: Use the Writer.\n}\n" 1522- uid: cloud.google.com/go/storage.ObjectHandle.ObjectName 1523 name: | 1524 func (*ObjectHandle) ObjectName 1525 id: ObjectName 1526 summary: | 1527 ObjectName returns the name of the object. 1528 parent: cloud.google.com/go/storage.ObjectHandle 1529 type: function 1530 langs: 1531 - go 1532 syntax: 1533 content: func (o *ObjectHandle) ObjectName() string 1534- uid: cloud.google.com/go/storage.ObjectHandle.ReadCompressed 1535 name: | 1536 func (*ObjectHandle) ReadCompressed 1537 id: ReadCompressed 1538 summary: | 1539 ReadCompressed when true causes the read to happen without decompressing. 1540 parent: cloud.google.com/go/storage.ObjectHandle 1541 type: function 1542 langs: 1543 - go 1544 syntax: 1545 content: func (o *ObjectHandle) ReadCompressed(compressed bool) *ObjectHandle 1546- uid: cloud.google.com/go/storage.ObjectHandle.Update 1547 name: | 1548 func (*ObjectHandle) Update 1549 id: Update 1550 summary: | 1551 Update updates an object with the provided attributes. 1552 All zero-value attributes are ignored. 1553 ErrObjectNotExist will be returned if the object is not found. 1554 parent: cloud.google.com/go/storage.ObjectHandle 1555 type: function 1556 langs: 1557 - go 1558 syntax: 1559 content: func (o *ObjectHandle) Update(ctx context.Context, uattrs ObjectAttrsToUpdate) (oa *ObjectAttrs, err error) 1560 codeexamples: 1561 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\t// Change only the content type of the object.\n\tobjAttrs, err := client.Bucket(\"my-bucket\").Object(\"my-object\").Update(ctx, storage.ObjectAttrsToUpdate{\n\t\tContentType: \"text/html\",\n\t\tContentDisposition: \"\", // delete ContentDisposition\n\t})\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Println(objAttrs)\n}\n" 1562- uid: cloud.google.com/go/storage.ObjectIterator 1563 name: ObjectIterator 1564 id: ObjectIterator 1565 summary: | 1566 An ObjectIterator is an iterator over ObjectAttrs. 1567 1568 Note: This iterator is not safe for concurrent operations without explicit synchronization. 1569 parent: cloud.google.com/go/storage 1570 type: type 1571 langs: 1572 - go 1573 syntax: 1574 content: "type ObjectIterator struct {\n\t// contains filtered or unexported fields\n}" 1575- uid: cloud.google.com/go/storage.ObjectIterator.Next 1576 name: | 1577 func (*ObjectIterator) Next 1578 id: Next 1579 summary: | 1580 Next returns the next result. Its second return value is iterator.Done if 1581 there are no more results. Once Next returns iterator.Done, all subsequent 1582 calls will return iterator.Done. 1583 1584 If Query.Delimiter is non-empty, some of the ObjectAttrs returned by Next will 1585 have a non-empty Prefix field, and a zero value for all other fields. These 1586 represent prefixes. 1587 1588 Note: This method is not safe for concurrent operations without explicit synchronization. 1589 parent: cloud.google.com/go/storage.ObjectIterator 1590 type: function 1591 langs: 1592 - go 1593 syntax: 1594 content: func (it *ObjectIterator) Next() (*ObjectAttrs, error) 1595 codeexamples: 1596 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n\t\"google.golang.org/api/iterator\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tit := client.Bucket(\"my-bucket\").Objects(ctx, nil)\n\tfor {\n\t\tobjAttrs, err := it.Next()\n\t\tif err == iterator.Done {\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\t// TODO: Handle error.\n\t\t}\n\t\tfmt.Println(objAttrs)\n\t}\n}\n" 1597- uid: cloud.google.com/go/storage.ObjectIterator.PageInfo 1598 name: | 1599 func (*ObjectIterator) PageInfo 1600 id: PageInfo 1601 summary: | 1602 PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1603 1604 Note: This method is not safe for concurrent operations without explicit synchronization. 1605 parent: cloud.google.com/go/storage.ObjectIterator 1606 type: function 1607 langs: 1608 - go 1609 syntax: 1610 content: func (it *ObjectIterator) PageInfo() *iterator.PageInfo 1611- uid: cloud.google.com/go/storage.PolicyV4Fields 1612 name: PolicyV4Fields 1613 id: PolicyV4Fields 1614 summary: | 1615 PolicyV4Fields describes the attributes for a PostPolicyV4 request. 1616 parent: cloud.google.com/go/storage 1617 type: type 1618 langs: 1619 - go 1620 syntax: 1621 content: "type PolicyV4Fields struct {\n\t// ACL specifies the access control permissions for the object.\n\t// Optional.\n\tACL string\n\t// CacheControl specifies the caching directives for the object.\n\t// Optional.\n\tCacheControl string\n\t// ContentType specifies the media type of the object.\n\t// Optional.\n\tContentType string\n\t// ContentDisposition specifies how the file will be served back to requesters.\n\t// Optional.\n\tContentDisposition string\n\t// ContentEncoding specifies the decompressive transcoding that the object.\n\t// This field is complementary to ContentType in that the file could be\n\t// compressed but ContentType specifies the file's original media type.\n\t// Optional.\n\tContentEncoding string\n\t// Metadata specifies custom metadata for the object.\n\t// If any key doesn't begin with \"x-goog-meta-\", an error will be returned.\n\t// Optional.\n\tMetadata map[string]string\n\t// StatusCodeOnSuccess when set, specifies the status code that Cloud Storage\n\t// will serve back on successful upload of the object.\n\t// Optional.\n\tStatusCodeOnSuccess int\n\t// RedirectToURLOnSuccess when set, specifies the URL that Cloud Storage\n\t// will serve back on successful upload of the object.\n\t// Optional.\n\tRedirectToURLOnSuccess string\n}" 1622- uid: cloud.google.com/go/storage.PostPolicyV4 1623 name: PostPolicyV4 1624 id: PostPolicyV4 1625 summary: | 1626 PostPolicyV4 describes the URL and respective form fields for a generated PostPolicyV4 request. 1627 parent: cloud.google.com/go/storage 1628 type: type 1629 langs: 1630 - go 1631 syntax: 1632 content: "type PostPolicyV4 struct {\n\t// URL is the generated URL that the file upload will be made to.\n\tURL string\n\t// Fields specifies the generated key-values that the file uploader\n\t// must include in their multipart upload form.\n\tFields map[string]string\n}" 1633- uid: cloud.google.com/go/storage.PostPolicyV4.GenerateSignedPostPolicyV4 1634 name: | 1635 func GenerateSignedPostPolicyV4 1636 id: GenerateSignedPostPolicyV4 1637 summary: | 1638 GenerateSignedPostPolicyV4 generates a PostPolicyV4 value from bucket, object and opts. 1639 The generated URL and fields will then allow an unauthenticated client to perform multipart uploads. 1640 parent: cloud.google.com/go/storage.PostPolicyV4 1641 type: function 1642 langs: 1643 - go 1644 syntax: 1645 content: func GenerateSignedPostPolicyV4(bucket, object string, opts *PostPolicyV4Options) (*PostPolicyV4, error) 1646 codeexamples: 1647 - content: "package main\n\nimport (\n\t\"bytes\"\n\t\"cloud.google.com/go/storage\"\n\t\"io\"\n\t\"mime/multipart\"\n\t\"net/http\"\n\t\"time\"\n)\n\nfunc main() {\n\tpv4, err := storage.GenerateSignedPostPolicyV4(\"my-bucket\", \"my-object.txt\", &storage.PostPolicyV4Options{\n\t\tGoogleAccessID: \"my-access-id\",\n\t\tPrivateKey: []byte(\"my-private-key\"),\n\n\t\t// The upload expires in 2hours.\n\t\tExpires: time.Now().Add(2 * time.Hour),\n\n\t\tFields: &storage.PolicyV4Fields{\n\t\t\tStatusCodeOnSuccess: 200,\n\t\t\tRedirectToURLOnSuccess: \"https://example.org/\",\n\t\t\t// It MUST only be a text file.\n\t\t\tContentType: \"text/plain\",\n\t\t},\n\n\t\t// The conditions that the uploaded file will be expected to conform to.\n\t\tConditions: []storage.PostPolicyV4Condition{\n\t\t\t// Make the file a maximum of 10mB.\n\t\t\tstorage.ConditionContentLengthRange(0, 10<<20),\n\t\t},\n\t})\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\n\t// Now you can upload your file using the generated post policy\n\t// with a plain HTTP client or even the browser.\n\tformBuf := new(bytes.Buffer)\n\tmw := multipart.NewWriter(formBuf)\n\tfor fieldName, value := range pv4.Fields {\n\t\tif err := mw.WriteField(fieldName, value); err != nil {\n\t\t\t// TODO: handle error.\n\t\t}\n\t}\n\tfile := bytes.NewReader(bytes.Repeat([]byte(\"a\"), 100))\n\n\tmf, err := mw.CreateFormFile(\"file\", \"myfile.txt\")\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tif _, err := io.Copy(mf, file); err != nil {\n\t\t// TODO: handle error.\n\t}\n\tif err := mw.Close(); err != nil {\n\t\t// TODO: handle error.\n\t}\n\n\t// Compose the request.\n\treq, err := http.NewRequest(\"POST\", pv4.URL, formBuf)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\t// Ensure the Content-Type is derived from the multipart writer.\n\treq.Header.Set(\"Content-Type\", mw.FormDataContentType())\n\tres, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\t_ = res\n}\n" 1648- uid: cloud.google.com/go/storage.PostPolicyV4Condition 1649 name: PostPolicyV4Condition 1650 id: PostPolicyV4Condition 1651 summary: | 1652 PostPolicyV4Condition describes the constraints that the subsequent 1653 object upload's multipart form fields will be expected to conform to. 1654 parent: cloud.google.com/go/storage 1655 type: type 1656 langs: 1657 - go 1658 syntax: 1659 content: "type PostPolicyV4Condition interface {\n\tjson.Marshaler\n\t// contains filtered or unexported methods\n}" 1660- uid: cloud.google.com/go/storage.PostPolicyV4Condition.ConditionContentLengthRange 1661 name: | 1662 func ConditionContentLengthRange 1663 id: ConditionContentLengthRange 1664 summary: | 1665 ConditionContentLengthRange constraints the limits that the 1666 multipart upload's range header will be expected to be within. 1667 parent: cloud.google.com/go/storage.PostPolicyV4Condition 1668 type: function 1669 langs: 1670 - go 1671 syntax: 1672 content: func ConditionContentLengthRange(start, end uint64) PostPolicyV4Condition 1673- uid: cloud.google.com/go/storage.PostPolicyV4Condition.ConditionStartsWith 1674 name: | 1675 func ConditionStartsWith 1676 id: ConditionStartsWith 1677 summary: | 1678 ConditionStartsWith checks that an attributes starts with value. 1679 An empty value will cause this condition to be ignored. 1680 parent: cloud.google.com/go/storage.PostPolicyV4Condition 1681 type: function 1682 langs: 1683 - go 1684 syntax: 1685 content: func ConditionStartsWith(key, value string) PostPolicyV4Condition 1686- uid: cloud.google.com/go/storage.PostPolicyV4Options 1687 name: PostPolicyV4Options 1688 id: PostPolicyV4Options 1689 summary: | 1690 PostPolicyV4Options are used to construct a signed post policy. 1691 Please see https://cloud.google.com/storage/docs/xml-api/post-object 1692 for reference about the fields. 1693 parent: cloud.google.com/go/storage 1694 type: type 1695 langs: 1696 - go 1697 syntax: 1698 content: "type PostPolicyV4Options struct {\n\t// GoogleAccessID represents the authorizer of the signed URL generation.\n\t// It is typically the Google service account client email address from\n\t// the Google Developers Console in the form of \"xxx@developer.gserviceaccount.com\".\n\t// Required.\n\tGoogleAccessID string\n\n\t// PrivateKey is the Google service account private key. It is obtainable\n\t// from the Google Developers Console.\n\t// At https://console.developers.google.com/project/<your-project-id>/apiui/credential,\n\t// create a service account client ID or reuse one of your existing service account\n\t// credentials. Click on the \"Generate new P12 key\" to generate and download\n\t// a new private key. Once you download the P12 file, use the following command\n\t// to convert it into a PEM file.\n\t//\n\t// $ openssl pkcs12 -in key.p12 -passin pass:notasecret -out key.pem -nodes\n\t//\n\t// Provide the contents of the PEM file as a byte slice.\n\t// Exactly one of PrivateKey or SignBytes must be non-nil.\n\tPrivateKey []byte\n\n\t// SignBytes is a function for implementing custom signing. For example, if\n\t// your application is running on Google App Engine, you can use\n\t// appengine's internal signing function:\n\t// ctx := appengine.NewContext(request)\n\t// acc, _ := appengine.ServiceAccount(ctx)\n\t// url, err := SignedURL(\"bucket\", \"object\", &SignedURLOptions{\n\t// \tGoogleAccessID: acc,\n\t// \tSignBytes: func(b []byte) ([]byte, error) {\n\t// \t\t_, signedBytes, err := appengine.SignBytes(ctx, b)\n\t// \t\treturn signedBytes, err\n\t// \t},\n\t// \t// etc.\n\t// })\n\t//\n\t// Exactly one of PrivateKey or SignBytes must be non-nil.\n\tSignBytes func(hashBytes []byte) (signature []byte, err error)\n\n\t// Expires is the expiration time on the signed URL.\n\t// It must be a time in the future.\n\t// Required.\n\tExpires time.Time\n\n\t// Style provides options for the type of URL to use. Options are\n\t// PathStyle (default), BucketBoundHostname, and VirtualHostedStyle. See\n\t// https://cloud.google.com/storage/docs/request-endpoints for details.\n\t// Optional.\n\tStyle URLStyle\n\n\t// Insecure when set indicates that the generated URL's scheme\n\t// will use \"http\" instead of \"https\" (default).\n\t// Optional.\n\tInsecure bool\n\n\t// Fields specifies the attributes of a PostPolicyV4 request.\n\t// When Fields is non-nil, its attributes must match those that will\n\t// passed into field Conditions.\n\t// Optional.\n\tFields *PolicyV4Fields\n\n\t// The conditions that the uploaded file will be expected to conform to.\n\t// When used, the failure of an upload to satisfy a condition will result in\n\t// a 4XX status code, back with the message describing the problem.\n\t// Optional.\n\tConditions []PostPolicyV4Condition\n}" 1699- uid: cloud.google.com/go/storage.ProjectTeam 1700 name: ProjectTeam 1701 id: ProjectTeam 1702 summary: | 1703 ProjectTeam is the project team associated with the entity, if any. 1704 parent: cloud.google.com/go/storage 1705 type: type 1706 langs: 1707 - go 1708 syntax: 1709 content: "type ProjectTeam struct {\n\tProjectNumber string\n\tTeam string\n}" 1710- uid: cloud.google.com/go/storage.Query 1711 name: Query 1712 id: Query 1713 summary: | 1714 Query represents a query to filter objects from a bucket. 1715 parent: cloud.google.com/go/storage 1716 type: type 1717 langs: 1718 - go 1719 syntax: 1720 content: "type Query struct {\n\t// Delimiter returns results in a directory-like fashion.\n\t// Results will contain only objects whose names, aside from the\n\t// prefix, do not contain delimiter. Objects whose names,\n\t// aside from the prefix, contain delimiter will have their name,\n\t// truncated after the delimiter, returned in prefixes.\n\t// Duplicate prefixes are omitted.\n\t// Optional.\n\tDelimiter string\n\n\t// Prefix is the prefix filter to query objects\n\t// whose names begin with this prefix.\n\t// Optional.\n\tPrefix string\n\n\t// Versions indicates whether multiple versions of the same\n\t// object will be included in the results.\n\tVersions bool\n\n\t// StartOffset is used to filter results to objects whose names are\n\t// lexicographically equal to or after startOffset. If endOffset is also set,\n\t// the objects listed will have names between startOffset (inclusive) and\n\t// endOffset (exclusive).\n\tStartOffset string\n\n\t// EndOffset is used to filter results to objects whose names are\n\t// lexicographically before endOffset. If startOffset is also set, the objects\n\t// listed will have names between startOffset (inclusive) and endOffset (exclusive).\n\tEndOffset string\n\t// contains filtered or unexported fields\n}" 1721- uid: cloud.google.com/go/storage.Query.SetAttrSelection 1722 name: | 1723 func (*Query) SetAttrSelection 1724 id: SetAttrSelection 1725 summary: | 1726 SetAttrSelection makes the query populate only specific attributes of 1727 objects. When iterating over objects, if you only need each object's name 1728 and size, pass []string{"Name", "Size"} to this method. Only these fields 1729 will be fetched for each object across the network; the other fields of 1730 ObjectAttr will remain at their default values. This is a performance 1731 optimization; for more information, see 1732 https://cloud.google.com/storage/docs/json_api/v1/how-tos/performance 1733 parent: cloud.google.com/go/storage.Query 1734 type: function 1735 langs: 1736 - go 1737 syntax: 1738 content: func (q *Query) SetAttrSelection(attrs []string) error 1739- uid: cloud.google.com/go/storage.Reader 1740 name: Reader 1741 id: Reader 1742 summary: | 1743 Reader reads a Cloud Storage object. 1744 It implements io.Reader. 1745 1746 Typically, a Reader computes the CRC of the downloaded content and compares it to 1747 the stored CRC, returning an error from Read if there is a mismatch. This integrity check 1748 is skipped if transcoding occurs. See https://cloud.google.com/storage/docs/transcoding. 1749 parent: cloud.google.com/go/storage 1750 type: type 1751 langs: 1752 - go 1753 syntax: 1754 content: "type Reader struct {\n\tAttrs ReaderObjectAttrs\n\t// contains filtered or unexported fields\n}" 1755- uid: cloud.google.com/go/storage.Reader.CacheControl 1756 name: | 1757 func (*Reader) CacheControl 1758 id: CacheControl 1759 summary: | 1760 CacheControl returns the cache control of the object. 1761 1762 Deprecated: use Reader.Attrs.CacheControl. 1763 parent: cloud.google.com/go/storage.Reader 1764 type: function 1765 langs: 1766 - go 1767 syntax: 1768 content: func (r *Reader) CacheControl() string 1769- uid: cloud.google.com/go/storage.Reader.Close 1770 name: | 1771 func (*Reader) Close 1772 id: Close 1773 summary: | 1774 Close closes the Reader. It must be called when done reading. 1775 parent: cloud.google.com/go/storage.Reader 1776 type: function 1777 langs: 1778 - go 1779 syntax: 1780 content: func (r *Reader) Close() error 1781- uid: cloud.google.com/go/storage.Reader.ContentEncoding 1782 name: | 1783 func (*Reader) ContentEncoding 1784 id: ContentEncoding 1785 summary: | 1786 ContentEncoding returns the content encoding of the object. 1787 1788 Deprecated: use Reader.Attrs.ContentEncoding. 1789 parent: cloud.google.com/go/storage.Reader 1790 type: function 1791 langs: 1792 - go 1793 syntax: 1794 content: func (r *Reader) ContentEncoding() string 1795- uid: cloud.google.com/go/storage.Reader.ContentType 1796 name: | 1797 func (*Reader) ContentType 1798 id: ContentType 1799 summary: | 1800 ContentType returns the content type of the object. 1801 1802 Deprecated: use Reader.Attrs.ContentType. 1803 parent: cloud.google.com/go/storage.Reader 1804 type: function 1805 langs: 1806 - go 1807 syntax: 1808 content: func (r *Reader) ContentType() string 1809- uid: cloud.google.com/go/storage.Reader.LastModified 1810 name: | 1811 func (*Reader) LastModified 1812 id: LastModified 1813 summary: | 1814 LastModified returns the value of the Last-Modified header. 1815 1816 Deprecated: use Reader.Attrs.LastModified. 1817 parent: cloud.google.com/go/storage.Reader 1818 type: function 1819 langs: 1820 - go 1821 syntax: 1822 content: func (r *Reader) LastModified() (time.Time, error) 1823- uid: cloud.google.com/go/storage.Reader.Read 1824 name: | 1825 func (*Reader) Read 1826 id: Read 1827 parent: cloud.google.com/go/storage.Reader 1828 type: function 1829 langs: 1830 - go 1831 syntax: 1832 content: func (r *Reader) Read(p []byte) (int, error) 1833- uid: cloud.google.com/go/storage.Reader.Remain 1834 name: | 1835 func (*Reader) Remain 1836 id: Remain 1837 summary: | 1838 Remain returns the number of bytes left to read, or -1 if unknown. 1839 parent: cloud.google.com/go/storage.Reader 1840 type: function 1841 langs: 1842 - go 1843 syntax: 1844 content: func (r *Reader) Remain() int64 1845- uid: cloud.google.com/go/storage.Reader.Size 1846 name: | 1847 func (*Reader) Size 1848 id: Size 1849 summary: | 1850 Size returns the size of the object in bytes. 1851 The returned value is always the same and is not affected by 1852 calls to Read or Close. 1853 1854 Deprecated: use Reader.Attrs.Size. 1855 parent: cloud.google.com/go/storage.Reader 1856 type: function 1857 langs: 1858 - go 1859 syntax: 1860 content: func (r *Reader) Size() int64 1861- uid: cloud.google.com/go/storage.ReaderObjectAttrs 1862 name: ReaderObjectAttrs 1863 id: ReaderObjectAttrs 1864 summary: | 1865 ReaderObjectAttrs are attributes about the object being read. These are populated 1866 during the New call. This struct only holds a subset of object attributes: to 1867 get the full set of attributes, use ObjectHandle.Attrs. 1868 1869 Each field is read-only. 1870 parent: cloud.google.com/go/storage 1871 type: type 1872 langs: 1873 - go 1874 syntax: 1875 content: "type ReaderObjectAttrs struct {\n\t// Size is the length of the object's content.\n\tSize int64\n\n\t// StartOffset is the byte offset within the object\n\t// from which reading begins.\n\t// This value is only non-zero for range requests.\n\tStartOffset int64\n\n\t// ContentType is the MIME type of the object's content.\n\tContentType string\n\n\t// ContentEncoding is the encoding of the object's content.\n\tContentEncoding string\n\n\t// CacheControl specifies whether and for how long browser and Internet\n\t// caches are allowed to cache your objects.\n\tCacheControl string\n\n\t// LastModified is the time that the object was last modified.\n\tLastModified time.Time\n\n\t// Generation is the generation number of the object's content.\n\tGeneration int64\n\n\t// Metageneration is the version of the metadata for this object at\n\t// this generation. This field is used for preconditions and for\n\t// detecting changes in metadata. A metageneration number is only\n\t// meaningful in the context of a particular generation of a\n\t// particular object.\n\tMetageneration int64\n}" 1876- uid: cloud.google.com/go/storage.RetentionPolicy 1877 name: RetentionPolicy 1878 id: RetentionPolicy 1879 summary: | 1880 RetentionPolicy enforces a minimum retention time for all objects 1881 contained in the bucket. 1882 1883 Any attempt to overwrite or delete objects younger than the retention 1884 period will result in an error. An unlocked retention policy can be 1885 modified or removed from the bucket via the Update method. A 1886 locked retention policy cannot be removed or shortened in duration 1887 for the lifetime of the bucket. 1888 1889 This feature is in private alpha release. It is not currently available to 1890 most customers. It might be changed in backwards-incompatible ways and is not 1891 subject to any SLA or deprecation policy. 1892 parent: cloud.google.com/go/storage 1893 type: type 1894 langs: 1895 - go 1896 syntax: 1897 content: "type RetentionPolicy struct {\n\t// RetentionPeriod specifies the duration that objects need to be\n\t// retained. Retention duration must be greater than zero and less than\n\t// 100 years. Note that enforcement of retention periods less than a day\n\t// is not guaranteed. Such periods should only be used for testing\n\t// purposes.\n\tRetentionPeriod time.Duration\n\n\t// EffectiveTime is the time from which the policy was enforced and\n\t// effective. This field is read-only.\n\tEffectiveTime time.Time\n\n\t// IsLocked describes whether the bucket is locked. Once locked, an\n\t// object retention policy cannot be modified.\n\t// This field is read-only.\n\tIsLocked bool\n}" 1898- uid: cloud.google.com/go/storage.SignedURLOptions 1899 name: SignedURLOptions 1900 id: SignedURLOptions 1901 summary: | 1902 SignedURLOptions allows you to restrict the access to the signed URL. 1903 parent: cloud.google.com/go/storage 1904 type: type 1905 langs: 1906 - go 1907 syntax: 1908 content: "type SignedURLOptions struct {\n\t// GoogleAccessID represents the authorizer of the signed URL generation.\n\t// It is typically the Google service account client email address from\n\t// the Google Developers Console in the form of \"xxx@developer.gserviceaccount.com\".\n\t// Required.\n\tGoogleAccessID string\n\n\t// PrivateKey is the Google service account private key. It is obtainable\n\t// from the Google Developers Console.\n\t// At https://console.developers.google.com/project/<your-project-id>/apiui/credential,\n\t// create a service account client ID or reuse one of your existing service account\n\t// credentials. Click on the \"Generate new P12 key\" to generate and download\n\t// a new private key. Once you download the P12 file, use the following command\n\t// to convert it into a PEM file.\n\t//\n\t// $ openssl pkcs12 -in key.p12 -passin pass:notasecret -out key.pem -nodes\n\t//\n\t// Provide the contents of the PEM file as a byte slice.\n\t// Exactly one of PrivateKey or SignBytes must be non-nil.\n\tPrivateKey []byte\n\n\t// SignBytes is a function for implementing custom signing. For example, if\n\t// your application is running on Google App Engine, you can use\n\t// appengine's internal signing function:\n\t// ctx := appengine.NewContext(request)\n\t// acc, _ := appengine.ServiceAccount(ctx)\n\t// url, err := SignedURL(\"bucket\", \"object\", &SignedURLOptions{\n\t// \tGoogleAccessID: acc,\n\t// \tSignBytes: func(b []byte) ([]byte, error) {\n\t// \t\t_, signedBytes, err := appengine.SignBytes(ctx, b)\n\t// \t\treturn signedBytes, err\n\t// \t},\n\t// \t// etc.\n\t// })\n\t//\n\t// Exactly one of PrivateKey or SignBytes must be non-nil.\n\tSignBytes func([]byte) ([]byte, error)\n\n\t// Method is the HTTP method to be used with the signed URL.\n\t// Signed URLs can be used with GET, HEAD, PUT, and DELETE requests.\n\t// Required.\n\tMethod string\n\n\t// Expires is the expiration time on the signed URL. It must be\n\t// a datetime in the future. For SigningSchemeV4, the expiration may be no\n\t// more than seven days in the future.\n\t// Required.\n\tExpires time.Time\n\n\t// ContentType is the content type header the client must provide\n\t// to use the generated signed URL.\n\t// Optional.\n\tContentType string\n\n\t// Headers is a list of extension headers the client must provide\n\t// in order to use the generated signed URL. Each must be a string of the\n\t// form \"key:values\", with multiple values separated by a semicolon.\n\t// Optional.\n\tHeaders []string\n\n\t// QueryParameters is a map of additional query parameters. When\n\t// SigningScheme is V4, this is used in computing the signature, and the\n\t// client must use the same query parameters when using the generated signed\n\t// URL.\n\t// Optional.\n\tQueryParameters url.Values\n\n\t// MD5 is the base64 encoded MD5 checksum of the file.\n\t// If provided, the client should provide the exact value on the request\n\t// header in order to use the signed URL.\n\t// Optional.\n\tMD5 string\n\n\t// Style provides options for the type of URL to use. Options are\n\t// PathStyle (default), BucketBoundHostname, and VirtualHostedStyle. See\n\t// https://cloud.google.com/storage/docs/request-endpoints for details.\n\t// Only supported for V4 signing.\n\t// Optional.\n\tStyle URLStyle\n\n\t// Insecure determines whether the signed URL should use HTTPS (default) or\n\t// HTTP.\n\t// Only supported for V4 signing.\n\t// Optional.\n\tInsecure bool\n\n\t// Scheme determines the version of URL signing to use. Default is\n\t// SigningSchemeV2.\n\tScheme SigningScheme\n}" 1909- uid: cloud.google.com/go/storage.SigningScheme 1910 name: SigningScheme 1911 id: SigningScheme 1912 summary: | 1913 SigningScheme determines the API version to use when signing URLs. 1914 parent: cloud.google.com/go/storage 1915 type: type 1916 langs: 1917 - go 1918 syntax: 1919 content: type SigningScheme int 1920- uid: cloud.google.com/go/storage.SigningSchemeDefault,SigningSchemeV2,SigningSchemeV4 1921 name: SigningSchemeDefault, SigningSchemeV2, SigningSchemeV4 1922 id: SigningSchemeDefault,SigningSchemeV2,SigningSchemeV4 1923 parent: cloud.google.com/go/storage.SigningScheme 1924 type: const 1925 langs: 1926 - go 1927 syntax: 1928 content: "const (\n\t// SigningSchemeDefault is presently V2 and will change to V4 in the future.\n\tSigningSchemeDefault SigningScheme = iota\n\n\t// SigningSchemeV2 uses the V2 scheme to sign URLs.\n\tSigningSchemeV2\n\n\t// SigningSchemeV4 uses the V4 scheme to sign URLs.\n\tSigningSchemeV4\n)" 1929- uid: cloud.google.com/go/storage.URLStyle 1930 name: URLStyle 1931 id: URLStyle 1932 summary: | 1933 URLStyle determines the style to use for the signed URL. pathStyle is the 1934 default. All non-default options work with V4 scheme only. See 1935 https://cloud.google.com/storage/docs/request-endpoints for details. 1936 parent: cloud.google.com/go/storage 1937 type: type 1938 langs: 1939 - go 1940 syntax: 1941 content: "type URLStyle interface {\n\t// contains filtered or unexported methods\n}" 1942- uid: cloud.google.com/go/storage.URLStyle.BucketBoundHostname 1943 name: | 1944 func BucketBoundHostname 1945 id: BucketBoundHostname 1946 summary: | 1947 BucketBoundHostname generates a URL with a custom hostname tied to a 1948 specific GCS bucket. The desired hostname should be passed in using the 1949 hostname argument. Generated urls will be of the form 1950 "<bucket-bound-hostname>/<object-name>". See 1951 https://cloud.google.com/storage/docs/request-endpoints#cname and 1952 https://cloud.google.com/load-balancing/docs/https/adding-backend-buckets-to-load-balancers 1953 for details. Note that for CNAMEs, only HTTP is supported, so Insecure must 1954 be set to true. 1955 parent: cloud.google.com/go/storage.URLStyle 1956 type: function 1957 langs: 1958 - go 1959 syntax: 1960 content: func BucketBoundHostname(hostname string) URLStyle 1961- uid: cloud.google.com/go/storage.URLStyle.PathStyle 1962 name: | 1963 func PathStyle 1964 id: PathStyle 1965 summary: | 1966 PathStyle is the default style, and will generate a URL of the form 1967 "storage.googleapis.com/<bucket-name>/<object-name>". 1968 parent: cloud.google.com/go/storage.URLStyle 1969 type: function 1970 langs: 1971 - go 1972 syntax: 1973 content: func PathStyle() URLStyle 1974- uid: cloud.google.com/go/storage.URLStyle.VirtualHostedStyle 1975 name: | 1976 func VirtualHostedStyle 1977 id: VirtualHostedStyle 1978 summary: | 1979 VirtualHostedStyle generates a URL relative to the bucket's virtual 1980 hostname, e.g. "<bucket-name>.storage.googleapis.com/<object-name>". 1981 parent: cloud.google.com/go/storage.URLStyle 1982 type: function 1983 langs: 1984 - go 1985 syntax: 1986 content: func VirtualHostedStyle() URLStyle 1987- uid: cloud.google.com/go/storage.UniformBucketLevelAccess 1988 name: UniformBucketLevelAccess 1989 id: UniformBucketLevelAccess 1990 summary: | 1991 UniformBucketLevelAccess configures access checks to use only bucket-level IAM 1992 policies. 1993 parent: cloud.google.com/go/storage 1994 type: type 1995 langs: 1996 - go 1997 syntax: 1998 content: "type UniformBucketLevelAccess struct {\n\t// Enabled specifies whether access checks use only bucket-level IAM\n\t// policies. Enabled may be disabled until the locked time.\n\tEnabled bool\n\t// LockedTime specifies the deadline for changing Enabled from true to\n\t// false.\n\tLockedTime time.Time\n}" 1999- uid: cloud.google.com/go/storage.Writer 2000 name: Writer 2001 id: Writer 2002 summary: | 2003 A Writer writes a Cloud Storage object. 2004 parent: cloud.google.com/go/storage 2005 type: type 2006 langs: 2007 - go 2008 syntax: 2009 content: "type Writer struct {\n\t// ObjectAttrs are optional attributes to set on the object. Any attributes\n\t// must be initialized before the first Write call. Nil or zero-valued\n\t// attributes are ignored.\n\tObjectAttrs\n\n\t// SendCRC specifies whether to transmit a CRC32C field. It should be set\n\t// to true in addition to setting the Writer's CRC32C field, because zero\n\t// is a valid CRC and normally a zero would not be transmitted.\n\t// If a CRC32C is sent, and the data written does not match the checksum,\n\t// the write will be rejected.\n\tSendCRC32C bool\n\n\t// ChunkSize controls the maximum number of bytes of the object that the\n\t// Writer will attempt to send to the server in a single request. Objects\n\t// smaller than the size will be sent in a single request, while larger\n\t// objects will be split over multiple requests. The size will be rounded up\n\t// to the nearest multiple of 256K.\n\t//\n\t// ChunkSize will default to a reasonable value. If you perform many\n\t// concurrent writes of small objects (under ~8MB), you may wish set ChunkSize\n\t// to a value that matches your objects' sizes to avoid consuming large\n\t// amounts of memory. See\n\t// https://cloud.google.com/storage/docs/json_api/v1/how-tos/upload#size\n\t// for more information about performance trade-offs related to ChunkSize.\n\t//\n\t// If ChunkSize is set to zero, chunking will be disabled and the object will\n\t// be uploaded in a single request without the use of a buffer. This will\n\t// further reduce memory used during uploads, but will also prevent the writer\n\t// from retrying in case of a transient error from the server, since a buffer\n\t// is required in order to retry the failed request.\n\t//\n\t// ChunkSize must be set before the first Write call.\n\tChunkSize int\n\n\t// ProgressFunc can be used to monitor the progress of a large write.\n\t// operation. If ProgressFunc is not nil and writing requires multiple\n\t// calls to the underlying service (see\n\t// https://cloud.google.com/storage/docs/json_api/v1/how-tos/resumable-upload),\n\t// then ProgressFunc will be invoked after each call with the number of bytes of\n\t// content copied so far.\n\t//\n\t// ProgressFunc should return quickly without blocking.\n\tProgressFunc func(int64)\n\t// contains filtered or unexported fields\n}" 2010- uid: cloud.google.com/go/storage.Writer.Attrs 2011 name: | 2012 func (*Writer) Attrs 2013 id: Attrs 2014 summary: | 2015 Attrs returns metadata about a successfully-written object. 2016 It's only valid to call it after Close returns nil. 2017 parent: cloud.google.com/go/storage.Writer 2018 type: function 2019 langs: 2020 - go 2021 syntax: 2022 content: func (w *Writer) Attrs() *ObjectAttrs 2023- uid: cloud.google.com/go/storage.Writer.Close 2024 name: | 2025 func (*Writer) Close 2026 id: Close 2027 summary: | 2028 Close completes the write operation and flushes any buffered data. 2029 If Close doesn't return an error, metadata about the written object 2030 can be retrieved by calling Attrs. 2031 parent: cloud.google.com/go/storage.Writer 2032 type: function 2033 langs: 2034 - go 2035 syntax: 2036 content: func (w *Writer) Close() error 2037- uid: cloud.google.com/go/storage.Writer.CloseWithError 2038 name: | 2039 func (*Writer) CloseWithError 2040 id: CloseWithError 2041 summary: | 2042 CloseWithError aborts the write operation with the provided error. 2043 CloseWithError always returns nil. 2044 2045 Deprecated: cancel the context passed to NewWriter instead. 2046 parent: cloud.google.com/go/storage.Writer 2047 type: function 2048 langs: 2049 - go 2050 syntax: 2051 content: func (w *Writer) CloseWithError(err error) error 2052- uid: cloud.google.com/go/storage.Writer.Write 2053 name: | 2054 func (*Writer) Write 2055 id: Write 2056 summary: | 2057 Write appends to w. It implements the io.Writer interface. 2058 2059 Since writes happen asynchronously, Write may return a nil 2060 error even though the write failed (or will fail). Always 2061 use the error returned from Writer.Close to determine if 2062 the upload was successful. 2063 2064 Writes will be retried on transient errors from the server, unless 2065 Writer.ChunkSize has been set to zero. 2066 parent: cloud.google.com/go/storage.Writer 2067 type: function 2068 langs: 2069 - go 2070 syntax: 2071 content: func (w *Writer) Write(p []byte) (n int, err error) 2072 codeexamples: 2073 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\twc := client.Bucket(\"bucketname\").Object(\"filename1\").NewWriter(ctx)\n\twc.ContentType = \"text/plain\"\n\twc.ACL = []storage.ACLRule{{Entity: storage.AllUsers, Role: storage.RoleReader}}\n\tif _, err := wc.Write([]byte(\"hello world\")); err != nil {\n\t\t// TODO: handle error.\n\t\t// Note that Write may return nil in some error situations,\n\t\t// so always check the error from Close.\n\t}\n\tif err := wc.Close(); err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Println(\"updated object:\", wc.Attrs())\n}\n" 2074 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n\t\"hash/crc32\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tdata := []byte(\"verify me\")\n\twc := client.Bucket(\"bucketname\").Object(\"filename1\").NewWriter(ctx)\n\twc.CRC32C = crc32.Checksum(data, crc32.MakeTable(crc32.Castagnoli))\n\twc.SendCRC32C = true\n\tif _, err := wc.Write([]byte(\"hello world\")); err != nil {\n\t\t// TODO: handle error.\n\t\t// Note that Write may return nil in some error situations,\n\t\t// so always check the error from Close.\n\t}\n\tif err := wc.Close(); err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Println(\"updated object:\", wc.Attrs())\n}\n" 2075 name: checksum 2076 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tclient, err := storage.NewClient(ctx)\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\ttctx, cancel := context.WithTimeout(ctx, 30*time.Second)\n\tdefer cancel() // Cancel when done, whether we time out or not.\n\twc := client.Bucket(\"bucketname\").Object(\"filename1\").NewWriter(tctx)\n\twc.ContentType = \"text/plain\"\n\twc.ACL = []storage.ACLRule{{Entity: storage.AllUsers, Role: storage.RoleReader}}\n\tif _, err := wc.Write([]byte(\"hello world\")); err != nil {\n\t\t// TODO: handle error.\n\t\t// Note that Write may return nil in some error situations,\n\t\t// so always check the error from Close.\n\t}\n\tif err := wc.Close(); err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Println(\"updated object:\", wc.Attrs())\n}\n" 2077 name: timeout 2078- uid: cloud.google.com/go/storage.SignedURL 2079 name: | 2080 func SignedURL 2081 id: SignedURL 2082 summary: | 2083 SignedURL returns a URL for the specified object. Signed URLs allow 2084 the users access to a restricted resource for a limited time without having a 2085 Google account or signing in. For more information about the signed 2086 URLs, see https://cloud.google.com/storage/docs/accesscontrol#Signed-URLs. 2087 parent: cloud.google.com/go/storage 2088 type: function 2089 langs: 2090 - go 2091 syntax: 2092 content: func SignedURL(bucket, name string, opts *SignedURLOptions) (string, error) 2093 codeexamples: 2094 - content: "package main\n\nimport (\n\t\"cloud.google.com/go/storage\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"time\"\n)\n\nfunc main() {\n\tpkey, err := ioutil.ReadFile(\"my-private-key.pem\")\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\turl, err := storage.SignedURL(\"my-bucket\", \"my-object\", &storage.SignedURLOptions{\n\t\tGoogleAccessID: \"xxx@developer.gserviceaccount.com\",\n\t\tPrivateKey: pkey,\n\t\tMethod: \"GET\",\n\t\tExpires: time.Now().Add(48 * time.Hour),\n\t})\n\tif err != nil {\n\t\t// TODO: handle error.\n\t}\n\tfmt.Println(url)\n}\n" 2095