Debian Codegraph @

internal/godocfx/testdata/golden/cloud.google.com/go/[email protected]/index.yml

raw
1 ### YamlMime:UniversalReference
2 items:
3 - uid: cloud.google.com/go/storage
4 name: cloud.google.com/go/storage
5 id: storage
6 summary: |
7 <p>Package storage provides an easy way to work with Google Cloud Storage.
8 Google Cloud Storage stores data in named objects, which are grouped into buckets.
9 <p>More information about Google Cloud Storage is available at
10 <a href="https://cloud.google.com/storage/docs">https://cloud.google.com/storage/docs</a>.
11 <p>See <a href="https://pkg.go.dev/cloud.google.com/go">https://pkg.go.dev/cloud.google.com/go</a> for authentication, timeouts,
12 connection pooling and similar aspects of this package.
13 <h2 id="hdr-Creating_a_Client">Creating a Client</h2>
14 <p>To start working with this package, create a <a href="#Client">Client</a>:
15 <pre class="prettyprint">ctx := context.Background()
16 client, err := storage.NewClient(ctx)
17 if err != nil {
18 // TODO: Handle error.
19 }
20 </pre>
21 <p>The client will use your default application credentials. Clients should be
22 reused instead of created as needed. The methods of <a href="#Client">Client</a> are safe for
23 concurrent use by multiple goroutines.
24 <p>You may configure the client by passing in options from the <a href="https://pkg.go.dev/google.golang.org/api/option">google.golang.org/api/option</a>
25 package. You may also use options defined in this package, such as <a href="#WithJSONReads">WithJSONReads</a>.
26 <p>If you only wish to access public data, you can create
27 an unauthenticated client with
28 <pre class="prettyprint">client, err := storage.NewClient(ctx, option.WithoutAuthentication())
29 </pre>
30 <p>To use an emulator with this library, you can set the STORAGE_EMULATOR_HOST
31 environment variable to the address at which your emulator is running. This will
32 send requests to that address instead of to Cloud Storage. You can then create
33 and use a client as usual:
34 <pre class="prettyprint">// Set STORAGE_EMULATOR_HOST environment variable.
35 err := os.Setenv(&quot;STORAGE_EMULATOR_HOST&quot;, &quot;localhost:9000&quot;)
36 if err != nil {
37 // TODO: Handle error.
38 }
39
40 // Create client as usual.
41 client, err := storage.NewClient(ctx)
42 if err != nil {
43 // TODO: Handle error.
44 }
45
46 // This request is now directed to http://localhost:9000/storage/v1/b
47 // instead of https://storage.googleapis.com/storage/v1/b
48 if err := client.Bucket(&quot;my-bucket&quot;).Create(ctx, projectID, nil); err != nil {
49 // TODO: Handle error.
50 }
51 </pre>
52 <p>Please note that there is no official emulator for Cloud Storage.
53 <h2 id="hdr-Buckets">Buckets</h2>
54 <p>A Google Cloud Storage bucket is a collection of objects. To work with a
55 bucket, make a bucket handle:
56 <pre class="prettyprint">bkt := client.Bucket(bucketName)
57 </pre>
58 <p>A handle is a reference to a bucket. You can have a handle even if the
59 bucket doesn&apos;t exist yet. To create a bucket in Google Cloud Storage,
60 call <a href="#BucketHandle.Create">BucketHandle.Create</a>:
61 <pre class="prettyprint">if err := bkt.Create(ctx, projectID, nil); err != nil {
62 // TODO: Handle error.
63 }
64 </pre>
65 <p>Note that although buckets are associated with projects, bucket names are
66 global across all projects.
67 <p>Each bucket has associated metadata, represented in this package by
68 <a href="#BucketAttrs">BucketAttrs</a>. The third argument to <a href="#BucketHandle.Create">BucketHandle.Create</a> allows you to set
69 the initial <a href="#BucketAttrs">BucketAttrs</a> of a bucket. To retrieve a bucket&apos;s attributes, use
70 <a href="#BucketHandle.Attrs">BucketHandle.Attrs</a>:
71 <pre class="prettyprint">attrs, err := bkt.Attrs(ctx)
72 if err != nil {
73 // TODO: Handle error.
74 }
75 fmt.Printf(&quot;bucket %s, created at %s, is located in %s with storage class %s\n&quot;,
76 attrs.Name, attrs.Created, attrs.Location, attrs.StorageClass)
77 </pre>
78 <h2 id="hdr-Objects">Objects</h2>
79 <p>An object holds arbitrary data as a sequence of bytes, like a file. You
80 refer to objects using a handle, just as with buckets, but unlike buckets
81 you don&apos;t explicitly create an object. Instead, the first time you write
82 to an object it will be created. You can use the standard Go <a href="https://pkg.go.dev/io#Reader">io.Reader</a>
83 and <a href="https://pkg.go.dev/io#Writer">io.Writer</a> interfaces to read and write object data:
84 <pre class="prettyprint">obj := bkt.Object(&quot;data&quot;)
85 // Write something to obj.
86 // w implements io.Writer.
87 w := obj.NewWriter(ctx)
88 // Write some text to obj. This will either create the object or overwrite whatever is there already.
89 if _, err := fmt.Fprintf(w, &quot;This object contains text.\n&quot;); err != nil {
90 // TODO: Handle error.
91 }
92 // Close, just like writing a file.
93 if err := w.Close(); err != nil {
94 // TODO: Handle error.
95 }
96
97 // Read it back.
98 r, err := obj.NewReader(ctx)
99 if err != nil {
100 // TODO: Handle error.
101 }
102 defer r.Close()
103 if _, err := io.Copy(os.Stdout, r); err != nil {
104 // TODO: Handle error.
105 }
106 // Prints &quot;This object contains text.&quot;
107 </pre>
108 <p>Objects also have attributes, which you can fetch with <a href="#ObjectHandle.Attrs">ObjectHandle.Attrs</a>:
109 <pre class="prettyprint">objAttrs, err := obj.Attrs(ctx)
110 if err != nil {
111 // TODO: Handle error.
112 }
113 fmt.Printf(&quot;object %s has size %d and can be read using %s\n&quot;,
114 objAttrs.Name, objAttrs.Size, objAttrs.MediaLink)
115 </pre>
116 <h2 id="hdr-Listing_objects">Listing objects</h2>
117 <p>Listing objects in a bucket is done with the <a href="#BucketHandle.Objects">BucketHandle.Objects</a> method:
118 <pre class="prettyprint">query := &amp;storage.Query{Prefix: &quot;&quot;}
119
120 var names []string
121 it := bkt.Objects(ctx, query)
122 for {
123 attrs, err := it.Next()
124 if err == iterator.Done {
125 break
126 }
127 if err != nil {
128 log.Fatal(err)
129 }
130 names = append(names, attrs.Name)
131 }
132 </pre>
133 <p>Objects are listed lexicographically by name. To filter objects
134 lexicographically, [Query.StartOffset] and/or [Query.EndOffset] can be used:
135 <pre class="prettyprint">query := &amp;storage.Query{
136 Prefix: &quot;&quot;,
137 StartOffset: &quot;bar/&quot;, // Only list objects lexicographically &gt;= &quot;bar/&quot;
138 EndOffset: &quot;foo/&quot;, // Only list objects lexicographically &lt; &quot;foo/&quot;
139 }
140
141 // ... as before
142 </pre>
143 <p>If only a subset of object attributes is needed when listing, specifying this
144 subset using <a href="#Query.SetAttrSelection">Query.SetAttrSelection</a> may speed up the listing process:
145 <pre class="prettyprint">query := &amp;storage.Query{Prefix: &quot;&quot;}
146 query.SetAttrSelection([]string{&quot;Name&quot;})
147
148 // ... as before
149 </pre>
150 <h2 id="hdr-ACLs">ACLs</h2>
151 <p>Both objects and buckets have ACLs (Access Control Lists). An ACL is a list of
152 ACLRules, each of which specifies the role of a user, group or project. ACLs
153 are suitable for fine-grained control, but you may prefer using IAM to control
154 access at the project level (see <a href="https://cloud.google.com/storage/docs/access-control/iam">Cloud Storage IAM docs</a>.
155 <p>To list the ACLs of a bucket or object, obtain an <a href="#ACLHandle">ACLHandle</a> and call <a href="#ACLHandle.List">ACLHandle.List</a>:
156 <pre class="prettyprint">acls, err := obj.ACL().List(ctx)
157 if err != nil {
158 // TODO: Handle error.
159 }
160 for _, rule := range acls {
161 fmt.Printf(&quot;%s has role %s\n&quot;, rule.Entity, rule.Role)
162 }
163 </pre>
164 <p>You can also set and delete ACLs.
165 <h2 id="hdr-Conditions">Conditions</h2>
166 <p>Every object has a generation and a metageneration. The generation changes
167 whenever the content changes, and the metageneration changes whenever the
168 metadata changes. <a href="#Conditions">Conditions</a> let you check these values before an operation;
169 the operation only executes if the conditions match. You can use conditions to
170 prevent race conditions in read-modify-write operations.
171 <p>For example, say you&apos;ve read an object&apos;s metadata into objAttrs. Now
172 you want to write to that object, but only if its contents haven&apos;t changed
173 since you read it. Here is how to express that:
174 <pre class="prettyprint">w = obj.If(storage.Conditions{GenerationMatch: objAttrs.Generation}).NewWriter(ctx)
175 // Proceed with writing as above.
176 </pre>
177 <h2 id="hdr-Signed_URLs">Signed URLs</h2>
178 <p>You can obtain a URL that lets anyone read or write an object for a limited time.
179 Signing a URL requires credentials authorized to sign a URL. To use the same
180 authentication that was used when instantiating the Storage client, use
181 <a href="#BucketHandle.SignedURL">BucketHandle.SignedURL</a>.
182 <pre class="prettyprint">url, err := client.Bucket(bucketName).SignedURL(objectName, opts)
183 if err != nil {
184 // TODO: Handle error.
185 }
186 fmt.Println(url)
187 </pre>
188 <p>You can also sign a URL without creating a client. See the documentation of
189 <a href="#SignedURL">SignedURL</a> for details.
190 <pre class="prettyprint">url, err := storage.SignedURL(bucketName, &quot;shared-object&quot;, opts)
191 if err != nil {
192 // TODO: Handle error.
193 }
194 fmt.Println(url)
195 </pre>
196 <h2 id="hdr-Post_Policy_V4_Signed_Request">Post Policy V4 Signed Request</h2>
197 <p>A type of signed request that allows uploads through HTML forms directly to Cloud Storage with
198 temporary permission. Conditions can be applied to restrict how the HTML form is used and exercised
199 by a user.
200 <p>For more information, please see the <a href="https://cloud.google.com/storage/docs/xml-api/post-object">XML POST Object docs</a> as well
201 as the documentation of <a href="#BucketHandle.GenerateSignedPostPolicyV4">BucketHandle.GenerateSignedPostPolicyV4</a>.
202 <pre class="prettyprint">pv4, err := client.Bucket(bucketName).GenerateSignedPostPolicyV4(objectName, opts)
203 if err != nil {
204 // TODO: Handle error.
205 }
206 fmt.Printf(&quot;URL: %s\nFields; %v\n&quot;, pv4.URL, pv4.Fields)
207 </pre>
208 <h2 id="hdr-Credential_requirements_for_signing">Credential requirements for signing</h2>
209 <p>If the GoogleAccessID and PrivateKey option fields are not provided, they will
210 be automatically detected by <a href="#BucketHandle.SignedURL">BucketHandle.SignedURL</a> and
211 <a href="#BucketHandle.GenerateSignedPostPolicyV4">BucketHandle.GenerateSignedPostPolicyV4</a> if any of the following are true:
212 <ul>
213 <li>you are authenticated to the Storage Client with a service account&apos;s
214 downloaded private key, either directly in code or by setting the
215 GOOGLE_APPLICATION_CREDENTIALS environment variable (see <a href="https://cloud.google.com/storage/docs/authentication#libauth">Other Environments</a>),
216 <li>your application is running on Google Compute Engine (GCE), or
217 <li>you are logged into <a href="https://cloud.google.com/sdk/gcloud/reference/auth/application-default/login">gcloud using application default credentials</a>
218 with <a href="https://cloud.google.com/sdk/gcloud/reference#--impersonate-service-account">impersonation enabled</a>.
219 </ul>
220 <p>Detecting GoogleAccessID may not be possible if you are authenticated using a
221 token source or using <a href="https://pkg.go.dev/google.golang.org/api/option#WithHTTPClient">option.WithHTTPClient</a>. In this case, you can provide a
222 service account email for GoogleAccessID and the client will attempt to sign
223 the URL or Post Policy using that service account.
224 <p>To generate the signature, you must have:
225 <ul>
226 <li>iam.serviceAccounts.signBlob permissions on the GoogleAccessID service
227 account, and
228 <li>the <a href="https://console.developers.google.com/apis/api/iamcredentials.googleapis.com/overview">IAM Service Account Credentials API</a> enabled (unless authenticating
229 with a downloaded private key).
230 </ul>
231 <h2 id="hdr-Errors">Errors</h2>
232 <p>Errors returned by this client are often of the type <a href="https://pkg.go.dev/google.golang.org/api/googleapi#Error">googleapi.Error</a>.
233 These errors can be introspected for more information by using <a href="https://pkg.go.dev/errors#As">errors.As</a>
234 with the richer <a href="https://pkg.go.dev/google.golang.org/api/googleapi#Error">googleapi.Error</a> type. For example:
235 <pre class="prettyprint">var e &#42;googleapi.Error
236 if ok := errors.As(err, &amp;e); ok {
237 if e.Code == 409 { ... }
238 }
239 </pre>
240 <h2 id="hdr-Retrying_failed_requests">Retrying failed requests</h2>
241 <p>Methods in this package may retry calls that fail with transient errors.
242 Retrying continues indefinitely unless the controlling context is canceled, the
243 client is closed, or a non-transient error is received. To stop retries from
244 continuing, use context timeouts or cancellation.
245 <p>The retry strategy in this library follows best practices for Cloud Storage. By
246 default, operations are retried only if they are idempotent, and exponential
247 backoff with jitter is employed. In addition, errors are only retried if they
248 are defined as transient by the service. See the <a href="https://cloud.google.com/storage/docs/retry-strategy">Cloud Storage retry docs</a>
249 for more information.
250 <p>Users can configure non-default retry behavior for a single library call (using
251 <a href="#BucketHandle.Retryer">BucketHandle.Retryer</a> and <a href="#ObjectHandle.Retryer">ObjectHandle.Retryer</a>) or for all calls made by a
252 client (using <a href="#Client.SetRetry">Client.SetRetry</a>). For example:
253 <pre class="prettyprint">o := client.Bucket(bucket).Object(object).Retryer(
254 // Use WithBackoff to change the timing of the exponential backoff.
255 storage.WithBackoff(gax.Backoff{
256 Initial: 2 &#42; time.Second,
257 }),
258 // Use WithPolicy to configure the idempotency policy. RetryAlways will
259 // retry the operation even if it is non-idempotent.
260 storage.WithPolicy(storage.RetryAlways),
261 )
262
263 // Use a context timeout to set an overall deadline on the call, including all
264 // potential retries.
265 ctx, cancel := context.WithTimeout(ctx, 5&#42;time.Second)
266 defer cancel()
267
268 // Delete an object using the specified strategy and timeout.
269 if err := o.Delete(ctx); err != nil {
270 // Handle err.
271 }
272 </pre>
273 <h2 id="hdr-Sending_Custom_Headers">Sending Custom Headers</h2>
274 <p>You can add custom headers to any API call made by this package by using
275 <a href="https://pkg.go.dev/github.com/googleapis/gax-go/v2/callctx#SetHeaders">callctx.SetHeaders</a> on the context which is passed to the method. For example,
276 to add a <a href="https://cloud.google.com/storage/docs/audit-logging#add-custom-metadata">custom audit logging</a> header:
277 <pre class="prettyprint">ctx := context.Background()
278 ctx = callctx.SetHeaders(ctx, &quot;x-goog-custom-audit-&lt;key&gt;&quot;, &quot;&lt;value&gt;&quot;)
279 // Use client as usual with the context and the additional headers will be sent.
280 client.Bucket(&quot;my-bucket&quot;).Attrs(ctx)
281 </pre>
282 <h2 id="hdr-Experimental_gRPC_API">Experimental gRPC API</h2>
283 <p>This package includes support for the Cloud Storage gRPC API, which is currently
284 in preview. This implementation uses gRPC rather than the current JSON &amp; XML
285 APIs to make requests to Cloud Storage. If you would like to try the API,
286 please contact your GCP account rep for more information. The gRPC API is not
287 yet generally available, so it may be subject to breaking changes.
288 <p>To create a client which will use gRPC, use the alternate constructor:
289 <pre class="prettyprint">ctx := context.Background()
290 client, err := storage.NewGRPCClient(ctx)
291 if err != nil {
292 // TODO: Handle error.
293 }
294 // Use client as usual.
295 </pre>
296 <p>If the application is running within GCP, users may get better performance by
297 enabling DirectPath (enabling requests to skip some proxy steps). To enable,
298 set the environment variable `GOOGLE_CLOUD_ENABLE_DIRECT_PATH_XDS=true` and add
299 the following side-effect imports to your application:
300 <pre class="prettyprint">import (
301 _ &quot;google.golang.org/grpc/balancer/rls&quot;
302 _ &quot;google.golang.org/grpc/xds/googledirectpath&quot;
303 )
304 </pre>
305 type: package
306 langs:
307 - go
308 children:
309 - cloud.google.com/go/storage.DeleteAction,SetStorageClassAction,AbortIncompleteMPUAction
310 - cloud.google.com/go/storage.NoPayload,JSONPayload
311 - cloud.google.com/go/storage.ObjectFinalizeEvent,ObjectMetadataUpdateEvent,ObjectDeleteEvent,ObjectArchiveEvent
312 - cloud.google.com/go/storage.ScopeFullControl,ScopeReadOnly,ScopeReadWrite
313 - cloud.google.com/go/storage.ErrBucketNotExist,ErrObjectNotExist
314 - cloud.google.com/go/storage.ACLEntity
315 - cloud.google.com/go/storage.AllUsers,AllAuthenticatedUsers
316 - cloud.google.com/go/storage.ACLHandle
317 - cloud.google.com/go/storage.ACLHandle.Delete
318 - cloud.google.com/go/storage.ACLHandle.List
319 - cloud.google.com/go/storage.ACLHandle.Set
320 - cloud.google.com/go/storage.ACLRole
321 - cloud.google.com/go/storage.RoleOwner,RoleReader,RoleWriter
322 - cloud.google.com/go/storage.ACLRule
323 - cloud.google.com/go/storage.Autoclass
324 - cloud.google.com/go/storage.BucketAttrs
325 - cloud.google.com/go/storage.BucketAttrsToUpdate
326 - cloud.google.com/go/storage.BucketAttrsToUpdate.DeleteLabel
327 - cloud.google.com/go/storage.BucketAttrsToUpdate.SetLabel
328 - cloud.google.com/go/storage.BucketConditions
329 - cloud.google.com/go/storage.BucketEncryption
330 - cloud.google.com/go/storage.BucketHandle
331 - cloud.google.com/go/storage.BucketHandle.ACL
332 - cloud.google.com/go/storage.BucketHandle.AddNotification
333 - cloud.google.com/go/storage.BucketHandle.Attrs
334 - cloud.google.com/go/storage.BucketHandle.Create
335 - cloud.google.com/go/storage.BucketHandle.DefaultObjectACL
336 - cloud.google.com/go/storage.BucketHandle.Delete
337 - cloud.google.com/go/storage.BucketHandle.DeleteNotification
338 - cloud.google.com/go/storage.BucketHandle.GenerateSignedPostPolicyV4
339 - cloud.google.com/go/storage.BucketHandle.IAM
340 - cloud.google.com/go/storage.BucketHandle.If
341 - cloud.google.com/go/storage.BucketHandle.LockRetentionPolicy
342 - cloud.google.com/go/storage.BucketHandle.Notifications
343 - cloud.google.com/go/storage.BucketHandle.Object
344 - cloud.google.com/go/storage.BucketHandle.Objects
345 - cloud.google.com/go/storage.BucketHandle.Retryer
346 - cloud.google.com/go/storage.BucketHandle.SignedURL
347 - cloud.google.com/go/storage.BucketHandle.Update
348 - cloud.google.com/go/storage.BucketHandle.UserProject
349 - cloud.google.com/go/storage.BucketIterator
350 - cloud.google.com/go/storage.BucketIterator.Next
351 - cloud.google.com/go/storage.BucketIterator.PageInfo
352 - cloud.google.com/go/storage.BucketLogging
353 - cloud.google.com/go/storage.BucketPolicyOnly
354 - cloud.google.com/go/storage.BucketWebsite
355 - cloud.google.com/go/storage.CORS
356 - cloud.google.com/go/storage.Client
357 - cloud.google.com/go/storage.Client.NewClient
358 - cloud.google.com/go/storage.Client.NewGRPCClient
359 - cloud.google.com/go/storage.Client.Bucket
360 - cloud.google.com/go/storage.Client.Buckets
361 - cloud.google.com/go/storage.Client.Close
362 - cloud.google.com/go/storage.Client.CreateHMACKey
363 - cloud.google.com/go/storage.Client.HMACKeyHandle
364 - cloud.google.com/go/storage.Client.ListHMACKeys
365 - cloud.google.com/go/storage.Client.ServiceAccount
366 - cloud.google.com/go/storage.Client.SetRetry
367 - cloud.google.com/go/storage.Composer
368 - cloud.google.com/go/storage.Composer.Run
369 - cloud.google.com/go/storage.Conditions
370 - cloud.google.com/go/storage.Copier
371 - cloud.google.com/go/storage.Copier.Run
372 - cloud.google.com/go/storage.CustomPlacementConfig
373 - cloud.google.com/go/storage.HMACKey
374 - cloud.google.com/go/storage.HMACKeyAttrsToUpdate
375 - cloud.google.com/go/storage.HMACKeyHandle
376 - cloud.google.com/go/storage.HMACKeyHandle.Delete
377 - cloud.google.com/go/storage.HMACKeyHandle.Get
378 - cloud.google.com/go/storage.HMACKeyHandle.Update
379 - cloud.google.com/go/storage.HMACKeyOption
380 - cloud.google.com/go/storage.HMACKeyOption.ForHMACKeyServiceAccountEmail
381 - cloud.google.com/go/storage.HMACKeyOption.ShowDeletedHMACKeys
382 - cloud.google.com/go/storage.HMACKeyOption.UserProjectForHMACKeys
383 - cloud.google.com/go/storage.HMACKeysIterator
384 - cloud.google.com/go/storage.HMACKeysIterator.Next
385 - cloud.google.com/go/storage.HMACKeysIterator.PageInfo
386 - cloud.google.com/go/storage.HMACState
387 - cloud.google.com/go/storage.Active,Inactive,Deleted
388 - cloud.google.com/go/storage.Lifecycle
389 - cloud.google.com/go/storage.LifecycleAction
390 - cloud.google.com/go/storage.LifecycleCondition
391 - cloud.google.com/go/storage.LifecycleRule
392 - cloud.google.com/go/storage.Liveness
393 - cloud.google.com/go/storage.LiveAndArchived,Live,Archived
394 - cloud.google.com/go/storage.Notification
395 - cloud.google.com/go/storage.ObjectAttrs
396 - cloud.google.com/go/storage.ObjectAttrsToUpdate
397 - cloud.google.com/go/storage.ObjectHandle
398 - cloud.google.com/go/storage.ObjectHandle.ACL
399 - cloud.google.com/go/storage.ObjectHandle.Attrs
400 - cloud.google.com/go/storage.ObjectHandle.BucketName
401 - cloud.google.com/go/storage.ObjectHandle.ComposerFrom
402 - cloud.google.com/go/storage.ObjectHandle.CopierFrom
403 - cloud.google.com/go/storage.ObjectHandle.Delete
404 - cloud.google.com/go/storage.ObjectHandle.Generation
405 - cloud.google.com/go/storage.ObjectHandle.If
406 - cloud.google.com/go/storage.ObjectHandle.Key
407 - cloud.google.com/go/storage.ObjectHandle.NewRangeReader
408 - cloud.google.com/go/storage.ObjectHandle.NewReader
409 - cloud.google.com/go/storage.ObjectHandle.NewWriter
410 - cloud.google.com/go/storage.ObjectHandle.ObjectName
411 - cloud.google.com/go/storage.ObjectHandle.ReadCompressed
412 - cloud.google.com/go/storage.ObjectHandle.Retryer
413 - cloud.google.com/go/storage.ObjectHandle.Update
414 - cloud.google.com/go/storage.ObjectIterator
415 - cloud.google.com/go/storage.ObjectIterator.Next
416 - cloud.google.com/go/storage.ObjectIterator.PageInfo
417 - cloud.google.com/go/storage.PolicyV4Fields
418 - cloud.google.com/go/storage.PostPolicyV4
419 - cloud.google.com/go/storage.PostPolicyV4.GenerateSignedPostPolicyV4
420 - cloud.google.com/go/storage.PostPolicyV4Condition
421 - cloud.google.com/go/storage.PostPolicyV4Condition.ConditionContentLengthRange
422 - cloud.google.com/go/storage.PostPolicyV4Condition.ConditionStartsWith
423 - cloud.google.com/go/storage.PostPolicyV4Options
424 - cloud.google.com/go/storage.ProjectTeam
425 - cloud.google.com/go/storage.Projection
426 - cloud.google.com/go/storage.ProjectionDefault,ProjectionFull,ProjectionNoACL
427 - cloud.google.com/go/storage.Projection.String
428 - cloud.google.com/go/storage.PublicAccessPrevention
429 - cloud.google.com/go/storage.PublicAccessPreventionUnknown,PublicAccessPreventionUnspecified,PublicAccessPreventionEnforced,PublicAccessPreventionInherited
430 - cloud.google.com/go/storage.PublicAccessPrevention.String
431 - cloud.google.com/go/storage.Query
432 - cloud.google.com/go/storage.Query.SetAttrSelection
433 - cloud.google.com/go/storage.RPO
434 - cloud.google.com/go/storage.RPOUnknown,RPODefault,RPOAsyncTurbo
435 - cloud.google.com/go/storage.RPO.String
436 - cloud.google.com/go/storage.Reader
437 - cloud.google.com/go/storage.Reader.CacheControl
438 - cloud.google.com/go/storage.Reader.Close
439 - cloud.google.com/go/storage.Reader.ContentEncoding
440 - cloud.google.com/go/storage.Reader.ContentType
441 - cloud.google.com/go/storage.Reader.LastModified
442 - cloud.google.com/go/storage.Reader.Read
443 - cloud.google.com/go/storage.Reader.Remain
444 - cloud.google.com/go/storage.Reader.Size
445 - cloud.google.com/go/storage.ReaderObjectAttrs
446 - cloud.google.com/go/storage.RetentionPolicy
447 - cloud.google.com/go/storage.RetryOption
448 - cloud.google.com/go/storage.RetryOption.WithBackoff
449 - cloud.google.com/go/storage.RetryOption.WithErrorFunc
450 - cloud.google.com/go/storage.RetryOption.WithPolicy
451 - cloud.google.com/go/storage.RetryPolicy
452 - cloud.google.com/go/storage.RetryIdempotent,RetryAlways,RetryNever
453 - cloud.google.com/go/storage.SignedURLOptions
454 - cloud.google.com/go/storage.SigningScheme
455 - cloud.google.com/go/storage.SigningSchemeDefault,SigningSchemeV2,SigningSchemeV4
456 - cloud.google.com/go/storage.URLStyle
457 - cloud.google.com/go/storage.URLStyle.BucketBoundHostname
458 - cloud.google.com/go/storage.URLStyle.PathStyle
459 - cloud.google.com/go/storage.URLStyle.VirtualHostedStyle
460 - cloud.google.com/go/storage.UniformBucketLevelAccess
461 - cloud.google.com/go/storage.Writer
462 - cloud.google.com/go/storage.Writer.Attrs
463 - cloud.google.com/go/storage.Writer.Close
464 - cloud.google.com/go/storage.Writer.CloseWithError
465 - cloud.google.com/go/storage.Writer.Write
466 - cloud.google.com/go/storage.ShouldRetry
467 - cloud.google.com/go/storage.SignedURL
468 - cloud.google.com/go/storage.WithJSONReads
469 - cloud.google.com/go/storage.WithXMLReads
470 alt_link: https://pkg.go.dev/cloud.google.com/go/storage
471 friendlyApiName: Storage API
472 - uid: cloud.google.com/go/storage.DeleteAction,SetStorageClassAction,AbortIncompleteMPUAction
473 name: DeleteAction, SetStorageClassAction, AbortIncompleteMPUAction
474 id: DeleteAction,SetStorageClassAction,AbortIncompleteMPUAction
475 parent: cloud.google.com/go/storage
476 type: const
477 langs:
478 - go
479 syntax:
480 content: |-
481 const (
482
483 // DeleteAction is a lifecycle action that deletes a live and/or archived
484 // objects. Takes precedence over SetStorageClass actions.
485 DeleteAction = "Delete"
486
487 // SetStorageClassAction changes the storage class of live and/or archived
488 // objects.
489 SetStorageClassAction = "SetStorageClass"
490
491 // AbortIncompleteMPUAction is a lifecycle action that aborts an incomplete
492 // multipart upload when the multipart upload meets the conditions specified
493 // in the lifecycle rule. The AgeInDays condition is the only allowed
494 // condition for this action. AgeInDays is measured from the time the
495 // multipart upload was created.
496 AbortIncompleteMPUAction = "AbortIncompleteMultipartUpload"
497 )
498 - uid: cloud.google.com/go/storage.NoPayload,JSONPayload
499 name: NoPayload, JSONPayload
500 id: NoPayload,JSONPayload
501 summary: |
502 Values for Notification.PayloadFormat.
503 parent: cloud.google.com/go/storage
504 type: const
505 langs:
506 - go
507 syntax:
508 content: |-
509 const (
510 // Send no payload with notification messages.
511 NoPayload = "NONE"
512
513 // Send object metadata as JSON with notification messages.
514 JSONPayload = "JSON_API_V1"
515 )
516 - uid: cloud.google.com/go/storage.ObjectFinalizeEvent,ObjectMetadataUpdateEvent,ObjectDeleteEvent,ObjectArchiveEvent
517 name: ObjectFinalizeEvent, ObjectMetadataUpdateEvent, ObjectDeleteEvent, ObjectArchiveEvent
518 id: ObjectFinalizeEvent,ObjectMetadataUpdateEvent,ObjectDeleteEvent,ObjectArchiveEvent
519 summary: |
520 Values for Notification.EventTypes.
521 parent: cloud.google.com/go/storage
522 type: const
523 langs:
524 - go
525 syntax:
526 content: |-
527 const (
528 // Event that occurs when an object is successfully created.
529 ObjectFinalizeEvent = "OBJECT_FINALIZE"
530
531 // Event that occurs when the metadata of an existing object changes.
532 ObjectMetadataUpdateEvent = "OBJECT_METADATA_UPDATE"
533
534 // Event that occurs when an object is permanently deleted.
535 ObjectDeleteEvent = "OBJECT_DELETE"
536
537 // Event that occurs when the live version of an object becomes an
538 // archived version.
539 ObjectArchiveEvent = "OBJECT_ARCHIVE"
540 )
541 - uid: cloud.google.com/go/storage.ScopeFullControl,ScopeReadOnly,ScopeReadWrite
542 name: ScopeFullControl, ScopeReadOnly, ScopeReadWrite
543 id: ScopeFullControl,ScopeReadOnly,ScopeReadWrite
544 parent: cloud.google.com/go/storage
545 type: const
546 langs:
547 - go
548 syntax:
549 content: |-
550 const (
551 // ScopeFullControl grants permissions to manage your
552 // data and permissions in Google Cloud Storage.
553 ScopeFullControl = <a href="https://pkg.go.dev/google.golang.org/api/storage/v1">raw</a>.<a href="https://pkg.go.dev/google.golang.org/api/storage/v1#DevstorageFullControlScope">DevstorageFullControlScope</a>
554
555 // ScopeReadOnly grants permissions to
556 // view your data in Google Cloud Storage.
557 ScopeReadOnly = <a href="https://pkg.go.dev/google.golang.org/api/storage/v1">raw</a>.<a href="https://pkg.go.dev/google.golang.org/api/storage/v1#DevstorageReadOnlyScope">DevstorageReadOnlyScope</a>
558
559 // ScopeReadWrite grants permissions to manage your
560 // data in Google Cloud Storage.
561 ScopeReadWrite = <a href="https://pkg.go.dev/google.golang.org/api/storage/v1">raw</a>.<a href="https://pkg.go.dev/google.golang.org/api/storage/v1#DevstorageReadWriteScope">DevstorageReadWriteScope</a>
562 )
563 - uid: cloud.google.com/go/storage.ErrBucketNotExist,ErrObjectNotExist
564 name: ErrBucketNotExist, ErrObjectNotExist
565 id: ErrBucketNotExist,ErrObjectNotExist
566 parent: cloud.google.com/go/storage
567 type: variable
568 langs:
569 - go
570 syntax:
571 content: |-
572 var (
573 // ErrBucketNotExist indicates that the bucket does not exist.
574 ErrBucketNotExist = <a href="https://pkg.go.dev/errors">errors</a>.<a href="https://pkg.go.dev/errors#New">New</a>("storage: bucket doesn't exist")
575 // ErrObjectNotExist indicates that the object does not exist.
576 ErrObjectNotExist = <a href="https://pkg.go.dev/errors">errors</a>.<a href="https://pkg.go.dev/errors#New">New</a>("storage: object doesn't exist")
577 )
578 - uid: cloud.google.com/go/storage.ACLEntity
579 name: ACLEntity
580 id: ACLEntity
581 summary: |
582 ACLEntity refers to a user or group.
583 They are sometimes referred to as grantees.
584
585 It could be in the form of:
586 "user-<userId>", "user-<email>", "group-<groupId>", "group-<email>",
587 "domain-<domain>" and "project-team-<projectId>".
588
589 Or one of the predefined constants: AllUsers, AllAuthenticatedUsers.
590 parent: cloud.google.com/go/storage
591 type: type
592 langs:
593 - go
594 syntax:
595 content: type ACLEntity <a href="https://pkg.go.dev/builtin#string">string</a>
596 - uid: cloud.google.com/go/storage.AllUsers,AllAuthenticatedUsers
597 name: AllUsers, AllAuthenticatedUsers
598 id: AllUsers,AllAuthenticatedUsers
599 parent: cloud.google.com/go/storage.ACLEntity
600 type: const
601 langs:
602 - go
603 syntax:
604 content: |-
605 const (
606 AllUsers <a href="#cloud_google_com_go_storage_ACLEntity">ACLEntity</a> = "allUsers"
607 AllAuthenticatedUsers <a href="#cloud_google_com_go_storage_ACLEntity">ACLEntity</a> = "allAuthenticatedUsers"
608 )
609 - uid: cloud.google.com/go/storage.ACLHandle
610 name: ACLHandle
611 id: ACLHandle
612 summary: |
613 ACLHandle provides operations on an access control list for a Google Cloud Storage bucket or object.
614 ACLHandle on an object operates on the latest generation of that object by default.
615 Selecting a specific generation of an object is not currently supported by the client.
616 parent: cloud.google.com/go/storage
617 type: type
618 langs:
619 - go
620 syntax:
621 content: |-
622 type ACLHandle struct {
623 // contains filtered or unexported fields
624 }
625 - uid: cloud.google.com/go/storage.ACLHandle.Delete
626 name: |
627 func (*ACLHandle) Delete
628 id: Delete
629 summary: |
630 Delete permanently deletes the ACL entry for the given entity.
631 parent: cloud.google.com/go/storage.ACLHandle
632 type: method
633 langs:
634 - go
635 syntax:
636 content: func (a *<a href="#cloud_google_com_go_storage_ACLHandle">ACLHandle</a>) Delete(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, entity <a href="#cloud_google_com_go_storage_ACLEntity">ACLEntity</a>) (err <a href="https://pkg.go.dev/builtin#error">error</a>)
637 codeexamples:
638 - content: |
639 package main
640
641 import (
642 "context"
643
644 "cloud.google.com/go/storage"
645 )
646
647 func main() {
648 ctx := context.Background()
649 client, err := storage.NewClient(ctx)
650 if err != nil {
651 // TODO: handle error.
652 }
653 // No longer grant access to the bucket to everyone on the Internet.
654 if err := client.Bucket("my-bucket").ACL().Delete(ctx, storage.AllUsers); err != nil {
655 // TODO: handle error.
656 }
657 }
658 - uid: cloud.google.com/go/storage.ACLHandle.List
659 name: |
660 func (*ACLHandle) List
661 id: List
662 summary: |
663 List retrieves ACL entries.
664 parent: cloud.google.com/go/storage.ACLHandle
665 type: method
666 langs:
667 - go
668 syntax:
669 content: func (a *<a href="#cloud_google_com_go_storage_ACLHandle">ACLHandle</a>) List(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) (rules []<a href="#cloud_google_com_go_storage_ACLRule">ACLRule</a>, err <a href="https://pkg.go.dev/builtin#error">error</a>)
670 codeexamples:
671 - content: |
672 package main
673
674 import (
675 "context"
676 "fmt"
677
678 "cloud.google.com/go/storage"
679 )
680
681 func main() {
682 ctx := context.Background()
683 client, err := storage.NewClient(ctx)
684 if err != nil {
685 // TODO: handle error.
686 }
687 // List the default object ACLs for my-bucket.
688 aclRules, err := client.Bucket("my-bucket").DefaultObjectACL().List(ctx)
689 if err != nil {
690 // TODO: handle error.
691 }
692 fmt.Println(aclRules)
693 }
694 - uid: cloud.google.com/go/storage.ACLHandle.Set
695 name: |
696 func (*ACLHandle) Set
697 id: Set
698 summary: |
699 Set sets the role for the given entity.
700 parent: cloud.google.com/go/storage.ACLHandle
701 type: method
702 langs:
703 - go
704 syntax:
705 content: func (a *<a href="#cloud_google_com_go_storage_ACLHandle">ACLHandle</a>) Set(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, entity <a href="#cloud_google_com_go_storage_ACLEntity">ACLEntity</a>, role <a href="#cloud_google_com_go_storage_ACLRole">ACLRole</a>) (err <a href="https://pkg.go.dev/builtin#error">error</a>)
706 codeexamples:
707 - content: |
708 package main
709
710 import (
711 "context"
712
713 "cloud.google.com/go/storage"
714 )
715
716 func main() {
717 ctx := context.Background()
718 client, err := storage.NewClient(ctx)
719 if err != nil {
720 // TODO: handle error.
721 }
722 // Let any authenticated user read my-bucket/my-object.
723 obj := client.Bucket("my-bucket").Object("my-object")
724 if err := obj.ACL().Set(ctx, storage.AllAuthenticatedUsers, storage.RoleReader); err != nil {
725 // TODO: handle error.
726 }
727 }
728 - uid: cloud.google.com/go/storage.ACLRole
729 name: ACLRole
730 id: ACLRole
731 summary: |
732 ACLRole is the level of access to grant.
733 parent: cloud.google.com/go/storage
734 type: type
735 langs:
736 - go
737 syntax:
738 content: type ACLRole <a href="https://pkg.go.dev/builtin#string">string</a>
739 - uid: cloud.google.com/go/storage.RoleOwner,RoleReader,RoleWriter
740 name: RoleOwner, RoleReader, RoleWriter
741 id: RoleOwner,RoleReader,RoleWriter
742 parent: cloud.google.com/go/storage.ACLRole
743 type: const
744 langs:
745 - go
746 syntax:
747 content: |-
748 const (
749 RoleOwner <a href="#cloud_google_com_go_storage_ACLRole">ACLRole</a> = "OWNER"
750 RoleReader <a href="#cloud_google_com_go_storage_ACLRole">ACLRole</a> = "READER"
751 RoleWriter <a href="#cloud_google_com_go_storage_ACLRole">ACLRole</a> = "WRITER"
752 )
753 - uid: cloud.google.com/go/storage.ACLRule
754 name: ACLRule
755 id: ACLRule
756 summary: |
757 ACLRule represents a grant for a role to an entity (user, group or team) for a
758 Google Cloud Storage object or bucket.
759 parent: cloud.google.com/go/storage
760 type: type
761 langs:
762 - go
763 syntax:
764 content: |-
765 type ACLRule struct {
766 Entity <a href="#cloud_google_com_go_storage_ACLEntity">ACLEntity</a>
767 EntityID <a href="https://pkg.go.dev/builtin#string">string</a>
768 Role <a href="#cloud_google_com_go_storage_ACLRole">ACLRole</a>
769 Domain <a href="https://pkg.go.dev/builtin#string">string</a>
770 Email <a href="https://pkg.go.dev/builtin#string">string</a>
771 ProjectTeam *<a href="#cloud_google_com_go_storage_ProjectTeam">ProjectTeam</a>
772 }
773 - uid: cloud.google.com/go/storage.Autoclass
774 name: Autoclass
775 id: Autoclass
776 summary: |
777 Autoclass holds the bucket's autoclass configuration. If enabled,
778 allows for the automatic selection of the best storage class
779 based on object access patterns. See
780 https://cloud.google.com/storage/docs/using-autoclass for more information.
781 parent: cloud.google.com/go/storage
782 type: type
783 langs:
784 - go
785 syntax:
786 content: |-
787 type Autoclass struct {
788 // Enabled specifies whether the autoclass feature is enabled
789 // on the bucket.
790 Enabled <a href="https://pkg.go.dev/builtin#bool">bool</a>
791 // ToggleTime is the time from which Autoclass was last toggled.
792 // If Autoclass is enabled when the bucket is created, the ToggleTime
793 // is set to the bucket creation time. This field is read-only.
794 ToggleTime <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Time">Time</a>
795 }
796 - uid: cloud.google.com/go/storage.BucketAttrs
797 name: BucketAttrs
798 id: BucketAttrs
799 summary: |
800 BucketAttrs represents the metadata for a Google Cloud Storage bucket.
801 Read-only fields are ignored by BucketHandle.Create.
802 parent: cloud.google.com/go/storage
803 type: type
804 langs:
805 - go
806 syntax:
807 content: |-
808 type BucketAttrs struct {
809 // Name is the name of the bucket.
810 // This field is read-only.
811 Name <a href="https://pkg.go.dev/builtin#string">string</a>
812
813 // ACL is the list of access control rules on the bucket.
814 ACL []<a href="#cloud_google_com_go_storage_ACLRule">ACLRule</a>
815
816 // BucketPolicyOnly is an alias for UniformBucketLevelAccess. Use of
817 // UniformBucketLevelAccess is recommended above the use of this field.
818 // Setting BucketPolicyOnly.Enabled OR UniformBucketLevelAccess.Enabled to
819 // true, will enable UniformBucketLevelAccess.
820 BucketPolicyOnly <a href="#cloud_google_com_go_storage_BucketPolicyOnly">BucketPolicyOnly</a>
821
822 // UniformBucketLevelAccess configures access checks to use only bucket-level IAM
823 // policies and ignore any ACL rules for the bucket.
824 // See https://cloud.google.com/storage/docs/uniform-bucket-level-access
825 // for more information.
826 UniformBucketLevelAccess <a href="#cloud_google_com_go_storage_UniformBucketLevelAccess">UniformBucketLevelAccess</a>
827
828 // PublicAccessPrevention is the setting for the bucket's
829 // PublicAccessPrevention policy, which can be used to prevent public access
830 // of data in the bucket. See
831 // https://cloud.google.com/storage/docs/public-access-prevention for more
832 // information.
833 PublicAccessPrevention <a href="#cloud_google_com_go_storage_PublicAccessPrevention">PublicAccessPrevention</a>
834
835 // DefaultObjectACL is the list of access controls to
836 // apply to new objects when no object ACL is provided.
837 DefaultObjectACL []<a href="#cloud_google_com_go_storage_ACLRule">ACLRule</a>
838
839 // DefaultEventBasedHold is the default value for event-based hold on
840 // newly created objects in this bucket. It defaults to false.
841 DefaultEventBasedHold <a href="https://pkg.go.dev/builtin#bool">bool</a>
842
843 // If not empty, applies a predefined set of access controls. It should be set
844 // only when creating a bucket.
845 // It is always empty for BucketAttrs returned from the service.
846 // See https://cloud.google.com/storage/docs/json_api/v1/buckets/insert
847 // for valid values.
848 PredefinedACL <a href="https://pkg.go.dev/builtin#string">string</a>
849
850 // If not empty, applies a predefined set of default object access controls.
851 // It should be set only when creating a bucket.
852 // It is always empty for BucketAttrs returned from the service.
853 // See https://cloud.google.com/storage/docs/json_api/v1/buckets/insert
854 // for valid values.
855 PredefinedDefaultObjectACL <a href="https://pkg.go.dev/builtin#string">string</a>
856
857 // Location is the location of the bucket. It defaults to "US".
858 // If specifying a dual-region, CustomPlacementConfig should be set in conjunction.
859 Location <a href="https://pkg.go.dev/builtin#string">string</a>
860
861 // The bucket's custom placement configuration that holds a list of
862 // regional locations for custom dual regions.
863 CustomPlacementConfig *<a href="#cloud_google_com_go_storage_CustomPlacementConfig">CustomPlacementConfig</a>
864
865 // MetaGeneration is the metadata generation of the bucket.
866 // This field is read-only.
867 MetaGeneration <a href="https://pkg.go.dev/builtin#int64">int64</a>
868
869 // StorageClass is the default storage class of the bucket. This defines
870 // how objects in the bucket are stored and determines the SLA
871 // and the cost of storage. Typical values are "STANDARD", "NEARLINE",
872 // "COLDLINE" and "ARCHIVE". Defaults to "STANDARD".
873 // See https://cloud.google.com/storage/docs/storage-classes for all
874 // valid values.
875 StorageClass <a href="https://pkg.go.dev/builtin#string">string</a>
876
877 // Created is the creation time of the bucket.
878 // This field is read-only.
879 Created <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Time">Time</a>
880
881 // VersioningEnabled reports whether this bucket has versioning enabled.
882 VersioningEnabled <a href="https://pkg.go.dev/builtin#bool">bool</a>
883
884 // Labels are the bucket's labels.
885 Labels map[<a href="https://pkg.go.dev/builtin#string">string</a>]<a href="https://pkg.go.dev/builtin#string">string</a>
886
887 // RequesterPays reports whether the bucket is a Requester Pays bucket.
888 // Clients performing operations on Requester Pays buckets must provide
889 // a user project (see BucketHandle.UserProject), which will be billed
890 // for the operations.
891 RequesterPays <a href="https://pkg.go.dev/builtin#bool">bool</a>
892
893 // Lifecycle is the lifecycle configuration for objects in the bucket.
894 Lifecycle <a href="#cloud_google_com_go_storage_Lifecycle">Lifecycle</a>
895
896 // Retention policy enforces a minimum retention time for all objects
897 // contained in the bucket. A RetentionPolicy of nil implies the bucket
898 // has no minimum data retention.
899 //
900 // This feature is in private alpha release. It is not currently available to
901 // most customers. It might be changed in backwards-incompatible ways and is not
902 // subject to any SLA or deprecation policy.
903 RetentionPolicy *<a href="#cloud_google_com_go_storage_RetentionPolicy">RetentionPolicy</a>
904
905 // The bucket's Cross-Origin Resource Sharing (CORS) configuration.
906 CORS []<a href="#cloud_google_com_go_storage_CORS">CORS</a>
907
908 // The encryption configuration used by default for newly inserted objects.
909 Encryption *<a href="#cloud_google_com_go_storage_BucketEncryption">BucketEncryption</a>
910
911 // The logging configuration.
912 Logging *<a href="#cloud_google_com_go_storage_BucketLogging">BucketLogging</a>
913
914 // The website configuration.
915 Website *<a href="#cloud_google_com_go_storage_BucketWebsite">BucketWebsite</a>
916
917 // Etag is the HTTP/1.1 Entity tag for the bucket.
918 // This field is read-only.
919 Etag <a href="https://pkg.go.dev/builtin#string">string</a>
920
921 // LocationType describes how data is stored and replicated.
922 // Typical values are "multi-region", "region" and "dual-region".
923 // This field is read-only.
924 LocationType <a href="https://pkg.go.dev/builtin#string">string</a>
925
926 // The project number of the project the bucket belongs to.
927 // This field is read-only.
928 ProjectNumber <a href="https://pkg.go.dev/builtin#uint64">uint64</a>
929
930 // RPO configures the Recovery Point Objective (RPO) policy of the bucket.
931 // Set to RPOAsyncTurbo to turn on Turbo Replication for a bucket.
932 // See https://cloud.google.com/storage/docs/managing-turbo-replication for
933 // more information.
934 RPO <a href="#cloud_google_com_go_storage_RPO">RPO</a>
935
936 // Autoclass holds the bucket's autoclass configuration. If enabled,
937 // allows for the automatic selection of the best storage class
938 // based on object access patterns.
939 Autoclass *<a href="#cloud_google_com_go_storage_Autoclass">Autoclass</a>
940 }
941 - uid: cloud.google.com/go/storage.BucketAttrsToUpdate
942 name: BucketAttrsToUpdate
943 id: BucketAttrsToUpdate
944 summary: |
945 BucketAttrsToUpdate define the attributes to update during an Update call.
946 parent: cloud.google.com/go/storage
947 type: type
948 langs:
949 - go
950 syntax:
951 content: |-
952 type BucketAttrsToUpdate struct {
953 // If set, updates whether the bucket uses versioning.
954 VersioningEnabled <a href="https://pkg.go.dev/cloud.google.com/go/internal/optional">optional</a>.<a href="https://pkg.go.dev/cloud.google.com/go/internal/optional#Bool">Bool</a>
955
956 // If set, updates whether the bucket is a Requester Pays bucket.
957 RequesterPays <a href="https://pkg.go.dev/cloud.google.com/go/internal/optional">optional</a>.<a href="https://pkg.go.dev/cloud.google.com/go/internal/optional#Bool">Bool</a>
958
959 // DefaultEventBasedHold is the default value for event-based hold on
960 // newly created objects in this bucket.
961 DefaultEventBasedHold <a href="https://pkg.go.dev/cloud.google.com/go/internal/optional">optional</a>.<a href="https://pkg.go.dev/cloud.google.com/go/internal/optional#Bool">Bool</a>
962
963 // BucketPolicyOnly is an alias for UniformBucketLevelAccess. Use of
964 // UniformBucketLevelAccess is recommended above the use of this field.
965 // Setting BucketPolicyOnly.Enabled OR UniformBucketLevelAccess.Enabled to
966 // true, will enable UniformBucketLevelAccess. If both BucketPolicyOnly and
967 // UniformBucketLevelAccess are set, the value of UniformBucketLevelAccess
968 // will take precedence.
969 BucketPolicyOnly *<a href="#cloud_google_com_go_storage_BucketPolicyOnly">BucketPolicyOnly</a>
970
971 // UniformBucketLevelAccess configures access checks to use only bucket-level IAM
972 // policies and ignore any ACL rules for the bucket.
973 // See https://cloud.google.com/storage/docs/uniform-bucket-level-access
974 // for more information.
975 UniformBucketLevelAccess *<a href="#cloud_google_com_go_storage_UniformBucketLevelAccess">UniformBucketLevelAccess</a>
976
977 // PublicAccessPrevention is the setting for the bucket's
978 // PublicAccessPrevention policy, which can be used to prevent public access
979 // of data in the bucket. See
980 // https://cloud.google.com/storage/docs/public-access-prevention for more
981 // information.
982 PublicAccessPrevention <a href="#cloud_google_com_go_storage_PublicAccessPrevention">PublicAccessPrevention</a>
983
984 // StorageClass is the default storage class of the bucket. This defines
985 // how objects in the bucket are stored and determines the SLA
986 // and the cost of storage. Typical values are "STANDARD", "NEARLINE",
987 // "COLDLINE" and "ARCHIVE". Defaults to "STANDARD".
988 // See https://cloud.google.com/storage/docs/storage-classes for all
989 // valid values.
990 StorageClass <a href="https://pkg.go.dev/builtin#string">string</a>
991
992 // If set, updates the retention policy of the bucket. Using
993 // RetentionPolicy.RetentionPeriod = 0 will delete the existing policy.
994 //
995 // This feature is in private alpha release. It is not currently available to
996 // most customers. It might be changed in backwards-incompatible ways and is not
997 // subject to any SLA or deprecation policy.
998 RetentionPolicy *<a href="#cloud_google_com_go_storage_RetentionPolicy">RetentionPolicy</a>
999
1000 // If set, replaces the CORS configuration with a new configuration.
1001 // An empty (rather than nil) slice causes all CORS policies to be removed.
1002 CORS []<a href="#cloud_google_com_go_storage_CORS">CORS</a>
1003
1004 // If set, replaces the encryption configuration of the bucket. Using
1005 // BucketEncryption.DefaultKMSKeyName = "" will delete the existing
1006 // configuration.
1007 Encryption *<a href="#cloud_google_com_go_storage_BucketEncryption">BucketEncryption</a>
1008
1009 // If set, replaces the lifecycle configuration of the bucket.
1010 Lifecycle *<a href="#cloud_google_com_go_storage_Lifecycle">Lifecycle</a>
1011
1012 // If set, replaces the logging configuration of the bucket.
1013 Logging *<a href="#cloud_google_com_go_storage_BucketLogging">BucketLogging</a>
1014
1015 // If set, replaces the website configuration of the bucket.
1016 Website *<a href="#cloud_google_com_go_storage_BucketWebsite">BucketWebsite</a>
1017
1018 // If not empty, applies a predefined set of access controls.
1019 // See https://cloud.google.com/storage/docs/json_api/v1/buckets/patch.
1020 PredefinedACL <a href="https://pkg.go.dev/builtin#string">string</a>
1021
1022 // If not empty, applies a predefined set of default object access controls.
1023 // See https://cloud.google.com/storage/docs/json_api/v1/buckets/patch.
1024 PredefinedDefaultObjectACL <a href="https://pkg.go.dev/builtin#string">string</a>
1025
1026 // RPO configures the Recovery Point Objective (RPO) policy of the bucket.
1027 // Set to RPOAsyncTurbo to turn on Turbo Replication for a bucket.
1028 // See https://cloud.google.com/storage/docs/managing-turbo-replication for
1029 // more information.
1030 RPO <a href="#cloud_google_com_go_storage_RPO">RPO</a>
1031
1032 // If set, updates the autoclass configuration of the bucket.
1033 // See https://cloud.google.com/storage/docs/using-autoclass for more information.
1034 Autoclass *<a href="#cloud_google_com_go_storage_Autoclass">Autoclass</a>
1035 // contains filtered or unexported fields
1036 }
1037 - uid: cloud.google.com/go/storage.BucketAttrsToUpdate.DeleteLabel
1038 name: |
1039 func (*BucketAttrsToUpdate) DeleteLabel
1040 id: DeleteLabel
1041 summary: |
1042 DeleteLabel causes a label to be deleted when ua is used in a
1043 call to Bucket.Update.
1044 parent: cloud.google.com/go/storage.BucketAttrsToUpdate
1045 type: method
1046 langs:
1047 - go
1048 syntax:
1049 content: func (ua *<a href="#cloud_google_com_go_storage_BucketAttrsToUpdate">BucketAttrsToUpdate</a>) DeleteLabel(name <a href="https://pkg.go.dev/builtin#string">string</a>)
1050 - uid: cloud.google.com/go/storage.BucketAttrsToUpdate.SetLabel
1051 name: |
1052 func (*BucketAttrsToUpdate) SetLabel
1053 id: SetLabel
1054 summary: |
1055 SetLabel causes a label to be added or modified when ua is used
1056 in a call to Bucket.Update.
1057 parent: cloud.google.com/go/storage.BucketAttrsToUpdate
1058 type: method
1059 langs:
1060 - go
1061 syntax:
1062 content: func (ua *<a href="#cloud_google_com_go_storage_BucketAttrsToUpdate">BucketAttrsToUpdate</a>) SetLabel(name, value <a href="https://pkg.go.dev/builtin#string">string</a>)
1063 - uid: cloud.google.com/go/storage.BucketConditions
1064 name: BucketConditions
1065 id: BucketConditions
1066 summary: |
1067 BucketConditions constrain bucket methods to act on specific metagenerations.
1068
1069 The zero value is an empty set of constraints.
1070 parent: cloud.google.com/go/storage
1071 type: type
1072 langs:
1073 - go
1074 syntax:
1075 content: |-
1076 type BucketConditions struct {
1077 // MetagenerationMatch specifies that the bucket must have the given
1078 // metageneration for the operation to occur.
1079 // If MetagenerationMatch is zero, it has no effect.
1080 MetagenerationMatch <a href="https://pkg.go.dev/builtin#int64">int64</a>
1081
1082 // MetagenerationNotMatch specifies that the bucket must not have the given
1083 // metageneration for the operation to occur.
1084 // If MetagenerationNotMatch is zero, it has no effect.
1085 MetagenerationNotMatch <a href="https://pkg.go.dev/builtin#int64">int64</a>
1086 }
1087 - uid: cloud.google.com/go/storage.BucketEncryption
1088 name: BucketEncryption
1089 id: BucketEncryption
1090 summary: |
1091 BucketEncryption is a bucket's encryption configuration.
1092 parent: cloud.google.com/go/storage
1093 type: type
1094 langs:
1095 - go
1096 syntax:
1097 content: |-
1098 type BucketEncryption struct {
1099 // A Cloud KMS key name, in the form
1100 // projects/P/locations/L/keyRings/R/cryptoKeys/K, that will be used to encrypt
1101 // objects inserted into this bucket, if no encryption method is specified.
1102 // The key's location must be the same as the bucket's.
1103 DefaultKMSKeyName <a href="https://pkg.go.dev/builtin#string">string</a>
1104 }
1105 - uid: cloud.google.com/go/storage.BucketHandle
1106 name: BucketHandle
1107 id: BucketHandle
1108 summary: |
1109 BucketHandle provides operations on a Google Cloud Storage bucket.
1110 Use Client.Bucket to get a handle.
1111 parent: cloud.google.com/go/storage
1112 type: type
1113 langs:
1114 - go
1115 syntax:
1116 content: |-
1117 type BucketHandle struct {
1118 // contains filtered or unexported fields
1119 }
1120 codeexamples:
1121 - content: |
1122 package main
1123
1124 import (
1125 "context"
1126 "fmt"
1127
1128 "cloud.google.com/go/storage"
1129 )
1130
1131 func main() {
1132 ctx := context.Background()
1133 client, err := storage.NewClient(ctx)
1134 if err != nil {
1135 // TODO: handle error.
1136 }
1137
1138 attrs, err := client.Bucket("my-bucket").Attrs(ctx)
1139 if err == storage.ErrBucketNotExist {
1140 fmt.Println("The bucket does not exist")
1141 return
1142 }
1143 if err != nil {
1144 // TODO: handle error.
1145 }
1146 fmt.Printf("The bucket exists and has attributes: %#v\n", attrs)
1147 }
1148 name: exists
1149 - uid: cloud.google.com/go/storage.BucketHandle.ACL
1150 name: |
1151 func (*BucketHandle) ACL
1152 id: ACL
1153 summary: |
1154 ACL returns an ACLHandle, which provides access to the bucket's access control list.
1155 This controls who can list, create or overwrite the objects in a bucket.
1156 This call does not perform any network operations.
1157 parent: cloud.google.com/go/storage.BucketHandle
1158 type: method
1159 langs:
1160 - go
1161 syntax:
1162 content: func (b *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>) ACL() *<a href="#cloud_google_com_go_storage_ACLHandle">ACLHandle</a>
1163 - uid: cloud.google.com/go/storage.BucketHandle.AddNotification
1164 name: |
1165 func (*BucketHandle) AddNotification
1166 id: AddNotification
1167 summary: |
1168 AddNotification adds a notification to b. You must set n's TopicProjectID, TopicID
1169 and PayloadFormat, and must not set its ID. The other fields are all optional. The
1170 returned Notification's ID can be used to refer to it.
1171 parent: cloud.google.com/go/storage.BucketHandle
1172 type: method
1173 langs:
1174 - go
1175 syntax:
1176 content: func (b *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>) AddNotification(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, n *<a href="#cloud_google_com_go_storage_Notification">Notification</a>) (ret *<a href="#cloud_google_com_go_storage_Notification">Notification</a>, err <a href="https://pkg.go.dev/builtin#error">error</a>)
1177 codeexamples:
1178 - content: |
1179 package main
1180
1181 import (
1182 "context"
1183 "fmt"
1184
1185 "cloud.google.com/go/storage"
1186 )
1187
1188 func main() {
1189 ctx := context.Background()
1190 client, err := storage.NewClient(ctx)
1191 if err != nil {
1192 // TODO: handle error.
1193 }
1194 b := client.Bucket("my-bucket")
1195 n, err := b.AddNotification(ctx, &storage.Notification{
1196 TopicProjectID: "my-project",
1197 TopicID: "my-topic",
1198 PayloadFormat: storage.JSONPayload,
1199 })
1200 if err != nil {
1201 // TODO: handle error.
1202 }
1203 fmt.Println(n.ID)
1204 }
1205 - uid: cloud.google.com/go/storage.BucketHandle.Attrs
1206 name: |
1207 func (*BucketHandle) Attrs
1208 id: Attrs
1209 summary: |
1210 Attrs returns the metadata for the bucket.
1211 parent: cloud.google.com/go/storage.BucketHandle
1212 type: method
1213 langs:
1214 - go
1215 syntax:
1216 content: func (b *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>) Attrs(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) (attrs *<a href="#cloud_google_com_go_storage_BucketAttrs">BucketAttrs</a>, err <a href="https://pkg.go.dev/builtin#error">error</a>)
1217 codeexamples:
1218 - content: |
1219 package main
1220
1221 import (
1222 "context"
1223 "fmt"
1224
1225 "cloud.google.com/go/storage"
1226 )
1227
1228 func main() {
1229 ctx := context.Background()
1230 client, err := storage.NewClient(ctx)
1231 if err != nil {
1232 // TODO: handle error.
1233 }
1234 attrs, err := client.Bucket("my-bucket").Attrs(ctx)
1235 if err != nil {
1236 // TODO: handle error.
1237 }
1238 fmt.Println(attrs)
1239 }
1240 - uid: cloud.google.com/go/storage.BucketHandle.Create
1241 name: |
1242 func (*BucketHandle) Create
1243 id: Create
1244 summary: |
1245 Create creates the Bucket in the project.
1246 If attrs is nil the API defaults will be used.
1247 parent: cloud.google.com/go/storage.BucketHandle
1248 type: method
1249 langs:
1250 - go
1251 syntax:
1252 content: func (b *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>) Create(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, projectID <a href="https://pkg.go.dev/builtin#string">string</a>, attrs *<a href="#cloud_google_com_go_storage_BucketAttrs">BucketAttrs</a>) (err <a href="https://pkg.go.dev/builtin#error">error</a>)
1253 codeexamples:
1254 - content: |
1255 package main
1256
1257 import (
1258 "context"
1259
1260 "cloud.google.com/go/storage"
1261 )
1262
1263 func main() {
1264 ctx := context.Background()
1265 client, err := storage.NewClient(ctx)
1266 if err != nil {
1267 // TODO: handle error.
1268 }
1269 if err := client.Bucket("my-bucket").Create(ctx, "my-project", nil); err != nil {
1270 // TODO: handle error.
1271 }
1272 }
1273 - uid: cloud.google.com/go/storage.BucketHandle.DefaultObjectACL
1274 name: |
1275 func (*BucketHandle) DefaultObjectACL
1276 id: DefaultObjectACL
1277 summary: |
1278 DefaultObjectACL returns an ACLHandle, which provides access to the bucket's default object ACLs.
1279 These ACLs are applied to newly created objects in this bucket that do not have a defined ACL.
1280 This call does not perform any network operations.
1281 parent: cloud.google.com/go/storage.BucketHandle
1282 type: method
1283 langs:
1284 - go
1285 syntax:
1286 content: func (b *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>) DefaultObjectACL() *<a href="#cloud_google_com_go_storage_ACLHandle">ACLHandle</a>
1287 - uid: cloud.google.com/go/storage.BucketHandle.Delete
1288 name: |
1289 func (*BucketHandle) Delete
1290 id: Delete
1291 summary: |
1292 Delete deletes the Bucket.
1293 parent: cloud.google.com/go/storage.BucketHandle
1294 type: method
1295 langs:
1296 - go
1297 syntax:
1298 content: func (b *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>) Delete(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) (err <a href="https://pkg.go.dev/builtin#error">error</a>)
1299 codeexamples:
1300 - content: |
1301 package main
1302
1303 import (
1304 "context"
1305
1306 "cloud.google.com/go/storage"
1307 )
1308
1309 func main() {
1310 ctx := context.Background()
1311 client, err := storage.NewClient(ctx)
1312 if err != nil {
1313 // TODO: handle error.
1314 }
1315 if err := client.Bucket("my-bucket").Delete(ctx); err != nil {
1316 // TODO: handle error.
1317 }
1318 }
1319 - uid: cloud.google.com/go/storage.BucketHandle.DeleteNotification
1320 name: |
1321 func (*BucketHandle) DeleteNotification
1322 id: DeleteNotification
1323 summary: |
1324 DeleteNotification deletes the notification with the given ID.
1325 parent: cloud.google.com/go/storage.BucketHandle
1326 type: method
1327 langs:
1328 - go
1329 syntax:
1330 content: func (b *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>) DeleteNotification(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) (err <a href="https://pkg.go.dev/builtin#error">error</a>)
1331 codeexamples:
1332 - content: |
1333 package main
1334
1335 import (
1336 "context"
1337
1338 "cloud.google.com/go/storage"
1339 )
1340
1341 var notificationID string
1342
1343 func main() {
1344 ctx := context.Background()
1345 client, err := storage.NewClient(ctx)
1346 if err != nil {
1347 // TODO: handle error.
1348 }
1349 b := client.Bucket("my-bucket")
1350 // TODO: Obtain notificationID from BucketHandle.AddNotification
1351 // or BucketHandle.Notifications.
1352 err = b.DeleteNotification(ctx, notificationID)
1353 if err != nil {
1354 // TODO: handle error.
1355 }
1356 }
1357 - uid: cloud.google.com/go/storage.BucketHandle.GenerateSignedPostPolicyV4
1358 name: |
1359 func (*BucketHandle) GenerateSignedPostPolicyV4
1360 id: GenerateSignedPostPolicyV4
1361 summary: |
1362 GenerateSignedPostPolicyV4 generates a PostPolicyV4 value from bucket, object and opts.
1363 The generated URL and fields will then allow an unauthenticated client to perform multipart uploads.
1364
1365 This method requires the Expires field in the specified PostPolicyV4Options
1366 to be non-nil. You may need to set the GoogleAccessID and PrivateKey fields
1367 in some cases. Read more on the [automatic detection of credentials] for this method.
1368
1369 [automatic detection of credentials]: https://pkg.go.dev/cloud.google.com/go/storage#hdr-Credential_requirements_for_signing
1370 parent: cloud.google.com/go/storage.BucketHandle
1371 type: method
1372 langs:
1373 - go
1374 syntax:
1375 content: func (b *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>) GenerateSignedPostPolicyV4(object <a href="https://pkg.go.dev/builtin#string">string</a>, opts *<a href="#cloud_google_com_go_storage_PostPolicyV4Options">PostPolicyV4Options</a>) (*<a href="#cloud_google_com_go_storage_PostPolicyV4">PostPolicyV4</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)
1376 - uid: cloud.google.com/go/storage.BucketHandle.IAM
1377 name: |
1378 func (*BucketHandle) IAM
1379 id: IAM
1380 summary: |
1381 IAM provides access to IAM access control for the bucket.
1382 parent: cloud.google.com/go/storage.BucketHandle
1383 type: method
1384 langs:
1385 - go
1386 syntax:
1387 content: func (b *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>) IAM() *<a href="/go/docs/reference/cloud.google.com/go/iam/latest/">iam</a>.<a href="/go/docs/reference/cloud.google.com/go/iam/latest/#cloud_google_com_go_iam_Handle">Handle</a>
1388 - uid: cloud.google.com/go/storage.BucketHandle.If
1389 name: |
1390 func (*BucketHandle) If
1391 id: If
1392 summary: |
1393 If returns a new BucketHandle that applies a set of preconditions.
1394 Preconditions already set on the BucketHandle are ignored. The supplied
1395 BucketConditions must have exactly one field set to a non-zero value;
1396 otherwise an error will be returned from any operation on the BucketHandle.
1397 Operations on the new handle will return an error if the preconditions are not
1398 satisfied. The only valid preconditions for buckets are MetagenerationMatch
1399 and MetagenerationNotMatch.
1400 parent: cloud.google.com/go/storage.BucketHandle
1401 type: method
1402 langs:
1403 - go
1404 syntax:
1405 content: func (b *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>) If(conds <a href="#cloud_google_com_go_storage_BucketConditions">BucketConditions</a>) *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>
1406 - uid: cloud.google.com/go/storage.BucketHandle.LockRetentionPolicy
1407 name: |
1408 func (*BucketHandle) LockRetentionPolicy
1409 id: LockRetentionPolicy
1410 summary: |
1411 LockRetentionPolicy locks a bucket's retention policy until a previously-configured
1412 RetentionPeriod past the EffectiveTime. Note that if RetentionPeriod is set to less
1413 than a day, the retention policy is treated as a development configuration and locking
1414 will have no effect. The BucketHandle must have a metageneration condition that
1415 matches the bucket's metageneration. See BucketHandle.If.
1416
1417 This feature is in private alpha release. It is not currently available to
1418 most customers. It might be changed in backwards-incompatible ways and is not
1419 subject to any SLA or deprecation policy.
1420 parent: cloud.google.com/go/storage.BucketHandle
1421 type: method
1422 langs:
1423 - go
1424 syntax:
1425 content: func (b *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>) LockRetentionPolicy(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) <a href="https://pkg.go.dev/builtin#error">error</a>
1426 codeexamples:
1427 - content: |
1428 package main
1429
1430 import (
1431 "context"
1432
1433 "cloud.google.com/go/storage"
1434 )
1435
1436 func main() {
1437 ctx := context.Background()
1438 client, err := storage.NewClient(ctx)
1439 if err != nil {
1440 // TODO: handle error.
1441 }
1442 b := client.Bucket("my-bucket")
1443 attrs, err := b.Attrs(ctx)
1444 if err != nil {
1445 // TODO: handle error.
1446 }
1447 // Note that locking the bucket without first attaching a RetentionPolicy
1448 // that's at least 1 day is a no-op
1449 err = b.If(storage.BucketConditions{MetagenerationMatch: attrs.MetaGeneration}).LockRetentionPolicy(ctx)
1450 if err != nil {
1451 // TODO: handle err
1452 }
1453 }
1454 - uid: cloud.google.com/go/storage.BucketHandle.Notifications
1455 name: |
1456 func (*BucketHandle) Notifications
1457 id: Notifications
1458 summary: |
1459 Notifications returns all the Notifications configured for this bucket, as a map
1460 indexed by notification ID.
1461 parent: cloud.google.com/go/storage.BucketHandle
1462 type: method
1463 langs:
1464 - go
1465 syntax:
1466 content: func (b *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>) Notifications(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) (n map[<a href="https://pkg.go.dev/builtin#string">string</a>]*<a href="#cloud_google_com_go_storage_Notification">Notification</a>, err <a href="https://pkg.go.dev/builtin#error">error</a>)
1467 codeexamples:
1468 - content: |
1469 package main
1470
1471 import (
1472 "context"
1473 "fmt"
1474
1475 "cloud.google.com/go/storage"
1476 )
1477
1478 func main() {
1479 ctx := context.Background()
1480 client, err := storage.NewClient(ctx)
1481 if err != nil {
1482 // TODO: handle error.
1483 }
1484 b := client.Bucket("my-bucket")
1485 ns, err := b.Notifications(ctx)
1486 if err != nil {
1487 // TODO: handle error.
1488 }
1489 for id, n := range ns {
1490 fmt.Printf("%s: %+v\n", id, n)
1491 }
1492 }
1493 - uid: cloud.google.com/go/storage.BucketHandle.Object
1494 name: |
1495 func (*BucketHandle) Object
1496 id: Object
1497 summary: |
1498 Object returns an ObjectHandle, which provides operations on the named object.
1499 This call does not perform any network operations such as fetching the object or verifying its existence.
1500 Use methods on ObjectHandle to perform network operations.
1501
1502 name must consist entirely of valid UTF-8-encoded runes. The full specification
1503 for valid object names can be found at:
1504
1505 https://cloud.google.com/storage/docs/naming-objects
1506 parent: cloud.google.com/go/storage.BucketHandle
1507 type: method
1508 langs:
1509 - go
1510 syntax:
1511 content: func (b *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>) Object(name <a href="https://pkg.go.dev/builtin#string">string</a>) *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>
1512 - uid: cloud.google.com/go/storage.BucketHandle.Objects
1513 name: |
1514 func (*BucketHandle) Objects
1515 id: Objects
1516 summary: |
1517 Objects returns an iterator over the objects in the bucket that match the
1518 Query q. If q is nil, no filtering is done. Objects will be iterated over
1519 lexicographically by name.
1520
1521 Note: The returned iterator is not safe for concurrent operations without explicit synchronization.
1522 parent: cloud.google.com/go/storage.BucketHandle
1523 type: method
1524 langs:
1525 - go
1526 syntax:
1527 content: func (b *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>) Objects(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, q *<a href="#cloud_google_com_go_storage_Query">Query</a>) *<a href="#cloud_google_com_go_storage_ObjectIterator">ObjectIterator</a>
1528 codeexamples:
1529 - content: |
1530 package main
1531
1532 import (
1533 "context"
1534
1535 "cloud.google.com/go/storage"
1536 )
1537
1538 func main() {
1539 ctx := context.Background()
1540 client, err := storage.NewClient(ctx)
1541 if err != nil {
1542 // TODO: handle error.
1543 }
1544 it := client.Bucket("my-bucket").Objects(ctx, nil)
1545 _ = it // TODO: iterate using Next or iterator.Pager.
1546 }
1547 - uid: cloud.google.com/go/storage.BucketHandle.Retryer
1548 name: |
1549 func (*BucketHandle) Retryer
1550 id: Retryer
1551 summary: |
1552 Retryer returns a bucket handle that is configured with custom retry
1553 behavior as specified by the options that are passed to it. All operations
1554 on the new handle will use the customized retry configuration.
1555 Retry options set on a object handle will take precedence over options set on
1556 the bucket handle.
1557 These retry options will merge with the client's retry configuration (if set)
1558 for the returned handle. Options passed into this method will take precedence
1559 over retry options on the client. Note that you must explicitly pass in each
1560 option you want to override.
1561 parent: cloud.google.com/go/storage.BucketHandle
1562 type: method
1563 langs:
1564 - go
1565 syntax:
1566 content: func (b *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>) Retryer(opts ...<a href="#cloud_google_com_go_storage_RetryOption">RetryOption</a>) *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>
1567 - uid: cloud.google.com/go/storage.BucketHandle.SignedURL
1568 name: |
1569 func (*BucketHandle) SignedURL
1570 id: SignedURL
1571 summary: |
1572 SignedURL returns a URL for the specified object. Signed URLs allow anyone
1573 access to a restricted resource for a limited time without needing a Google
1574 account or signing in.
1575 For more information about signed URLs, see "[Overview of access control]."
1576
1577 This method requires the Method and Expires fields in the specified
1578 SignedURLOptions to be non-nil. You may need to set the GoogleAccessID and
1579 PrivateKey fields in some cases. Read more on the [automatic detection of credentials]
1580 for this method.
1581
1582 [Overview of access control]: https://cloud.google.com/storage/docs/accesscontrol#signed_urls_query_string_authentication
1583 [automatic detection of credentials]: https://pkg.go.dev/cloud.google.com/go/storage#hdr-Credential_requirements_for_signing
1584 parent: cloud.google.com/go/storage.BucketHandle
1585 type: method
1586 langs:
1587 - go
1588 syntax:
1589 content: func (b *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>) SignedURL(object <a href="https://pkg.go.dev/builtin#string">string</a>, opts *<a href="#cloud_google_com_go_storage_SignedURLOptions">SignedURLOptions</a>) (<a href="https://pkg.go.dev/builtin#string">string</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)
1590 - uid: cloud.google.com/go/storage.BucketHandle.Update
1591 name: |
1592 func (*BucketHandle) Update
1593 id: Update
1594 summary: |
1595 Update updates a bucket's attributes.
1596 parent: cloud.google.com/go/storage.BucketHandle
1597 type: method
1598 langs:
1599 - go
1600 syntax:
1601 content: func (b *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>) Update(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, uattrs <a href="#cloud_google_com_go_storage_BucketAttrsToUpdate">BucketAttrsToUpdate</a>) (attrs *<a href="#cloud_google_com_go_storage_BucketAttrs">BucketAttrs</a>, err <a href="https://pkg.go.dev/builtin#error">error</a>)
1602 codeexamples:
1603 - content: |
1604 package main
1605
1606 import (
1607 "context"
1608 "fmt"
1609
1610 "cloud.google.com/go/storage"
1611 )
1612
1613 func main() {
1614 ctx := context.Background()
1615 client, err := storage.NewClient(ctx)
1616 if err != nil {
1617 // TODO: handle error.
1618 }
1619 // Enable versioning in the bucket, regardless of its previous value.
1620 attrs, err := client.Bucket("my-bucket").Update(ctx,
1621 storage.BucketAttrsToUpdate{VersioningEnabled: true})
1622 if err != nil {
1623 // TODO: handle error.
1624 }
1625 fmt.Println(attrs)
1626 }
1627 - content: |
1628 package main
1629
1630 import (
1631 "context"
1632 "fmt"
1633
1634 "cloud.google.com/go/storage"
1635 )
1636
1637 func main() {
1638 ctx := context.Background()
1639 client, err := storage.NewClient(ctx)
1640 if err != nil {
1641 // TODO: handle error.
1642 }
1643 b := client.Bucket("my-bucket")
1644 attrs, err := b.Attrs(ctx)
1645 if err != nil {
1646 // TODO: handle error.
1647 }
1648 var au storage.BucketAttrsToUpdate
1649 au.SetLabel("lab", attrs.Labels["lab"]+"-more")
1650 if attrs.Labels["delete-me"] == "yes" {
1651 au.DeleteLabel("delete-me")
1652 }
1653 attrs, err = b.
1654 If(storage.BucketConditions{MetagenerationMatch: attrs.MetaGeneration}).
1655 Update(ctx, au)
1656 if err != nil {
1657 // TODO: handle error.
1658 }
1659 fmt.Println(attrs)
1660 }
1661 name: readModifyWrite
1662 - uid: cloud.google.com/go/storage.BucketHandle.UserProject
1663 name: |
1664 func (*BucketHandle) UserProject
1665 id: UserProject
1666 summary: |
1667 UserProject returns a new BucketHandle that passes the project ID as the user
1668 project for all subsequent calls. Calls with a user project will be billed to that
1669 project rather than to the bucket's owning project.
1670
1671 A user project is required for all operations on Requester Pays buckets.
1672 parent: cloud.google.com/go/storage.BucketHandle
1673 type: method
1674 langs:
1675 - go
1676 syntax:
1677 content: func (b *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>) UserProject(projectID <a href="https://pkg.go.dev/builtin#string">string</a>) *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>
1678 - uid: cloud.google.com/go/storage.BucketIterator
1679 name: BucketIterator
1680 id: BucketIterator
1681 summary: |
1682 A BucketIterator is an iterator over BucketAttrs.
1683
1684 Note: This iterator is not safe for concurrent operations without explicit synchronization.
1685 parent: cloud.google.com/go/storage
1686 type: type
1687 langs:
1688 - go
1689 syntax:
1690 content: |-
1691 type BucketIterator struct {
1692 // Prefix restricts the iterator to buckets whose names begin with it.
1693 Prefix <a href="https://pkg.go.dev/builtin#string">string</a>
1694 // contains filtered or unexported fields
1695 }
1696 - uid: cloud.google.com/go/storage.BucketIterator.Next
1697 name: |
1698 func (*BucketIterator) Next
1699 id: Next
1700 summary: |
1701 Next returns the next result. Its second return value is iterator.Done if
1702 there are no more results. Once Next returns iterator.Done, all subsequent
1703 calls will return iterator.Done.
1704
1705 Note: This method is not safe for concurrent operations without explicit synchronization.
1706 parent: cloud.google.com/go/storage.BucketIterator
1707 type: method
1708 langs:
1709 - go
1710 syntax:
1711 content: func (it *<a href="#cloud_google_com_go_storage_BucketIterator">BucketIterator</a>) Next() (*<a href="#cloud_google_com_go_storage_BucketAttrs">BucketAttrs</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)
1712 codeexamples:
1713 - content: |
1714 package main
1715
1716 import (
1717 "context"
1718 "fmt"
1719
1720 "cloud.google.com/go/storage"
1721 "google.golang.org/api/iterator"
1722 )
1723
1724 func main() {
1725 ctx := context.Background()
1726 client, err := storage.NewClient(ctx)
1727 if err != nil {
1728 // TODO: handle error.
1729 }
1730 it := client.Buckets(ctx, "my-project")
1731 for {
1732 bucketAttrs, err := it.Next()
1733 if err == iterator.Done {
1734 break
1735 }
1736 if err != nil {
1737 // TODO: Handle error.
1738 }
1739 fmt.Println(bucketAttrs)
1740 }
1741 }
1742 - uid: cloud.google.com/go/storage.BucketIterator.PageInfo
1743 name: |
1744 func (*BucketIterator) PageInfo
1745 id: PageInfo
1746 summary: |
1747 PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
1748
1749 Note: This method is not safe for concurrent operations without explicit synchronization.
1750 parent: cloud.google.com/go/storage.BucketIterator
1751 type: method
1752 langs:
1753 - go
1754 syntax:
1755 content: func (it *<a href="#cloud_google_com_go_storage_BucketIterator">BucketIterator</a>) PageInfo() *<a href="https://pkg.go.dev/google.golang.org/api/iterator">iterator</a>.<a href="https://pkg.go.dev/google.golang.org/api/iterator#PageInfo">PageInfo</a>
1756 - uid: cloud.google.com/go/storage.BucketLogging
1757 name: BucketLogging
1758 id: BucketLogging
1759 summary: |
1760 BucketLogging holds the bucket's logging configuration, which defines the
1761 destination bucket and optional name prefix for the current bucket's
1762 logs.
1763 parent: cloud.google.com/go/storage
1764 type: type
1765 langs:
1766 - go
1767 syntax:
1768 content: |-
1769 type BucketLogging struct {
1770 // The destination bucket where the current bucket's logs
1771 // should be placed.
1772 LogBucket <a href="https://pkg.go.dev/builtin#string">string</a>
1773
1774 // A prefix for log object names.
1775 LogObjectPrefix <a href="https://pkg.go.dev/builtin#string">string</a>
1776 }
1777 - uid: cloud.google.com/go/storage.BucketPolicyOnly
1778 name: BucketPolicyOnly
1779 id: BucketPolicyOnly
1780 summary: |
1781 BucketPolicyOnly is an alias for UniformBucketLevelAccess.
1782 Use of UniformBucketLevelAccess is preferred above BucketPolicyOnly.
1783 parent: cloud.google.com/go/storage
1784 type: type
1785 langs:
1786 - go
1787 syntax:
1788 content: |-
1789 type BucketPolicyOnly struct {
1790 // Enabled specifies whether access checks use only bucket-level IAM
1791 // policies. Enabled may be disabled until the locked time.
1792 Enabled <a href="https://pkg.go.dev/builtin#bool">bool</a>
1793 // LockedTime specifies the deadline for changing Enabled from true to
1794 // false.
1795 LockedTime <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Time">Time</a>
1796 }
1797 - uid: cloud.google.com/go/storage.BucketWebsite
1798 name: BucketWebsite
1799 id: BucketWebsite
1800 summary: |
1801 BucketWebsite holds the bucket's website configuration, controlling how the
1802 service behaves when accessing bucket contents as a web site. See
1803 https://cloud.google.com/storage/docs/static-website for more information.
1804 parent: cloud.google.com/go/storage
1805 type: type
1806 langs:
1807 - go
1808 syntax:
1809 content: |-
1810 type BucketWebsite struct {
1811 // If the requested object path is missing, the service will ensure the path has
1812 // a trailing '/', append this suffix, and attempt to retrieve the resulting
1813 // object. This allows the creation of index.html objects to represent directory
1814 // pages.
1815 MainPageSuffix <a href="https://pkg.go.dev/builtin#string">string</a>
1816
1817 // If the requested object path is missing, and any mainPageSuffix object is
1818 // missing, if applicable, the service will return the named object from this
1819 // bucket as the content for a 404 Not Found result.
1820 NotFoundPage <a href="https://pkg.go.dev/builtin#string">string</a>
1821 }
1822 - uid: cloud.google.com/go/storage.CORS
1823 name: CORS
1824 id: CORS
1825 summary: |
1826 CORS is the bucket's Cross-Origin Resource Sharing (CORS) configuration.
1827 parent: cloud.google.com/go/storage
1828 type: type
1829 langs:
1830 - go
1831 syntax:
1832 content: |-
1833 type CORS struct {
1834 // MaxAge is the value to return in the Access-Control-Max-Age
1835 // header used in preflight responses.
1836 MaxAge <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Duration">Duration</a>
1837
1838 // Methods is the list of HTTP methods on which to include CORS response
1839 // headers, (GET, OPTIONS, POST, etc) Note: "*" is permitted in the list
1840 // of methods, and means "any method".
1841 Methods []<a href="https://pkg.go.dev/builtin#string">string</a>
1842
1843 // Origins is the list of Origins eligible to receive CORS response
1844 // headers. Note: "*" is permitted in the list of origins, and means
1845 // "any Origin".
1846 Origins []<a href="https://pkg.go.dev/builtin#string">string</a>
1847
1848 // ResponseHeaders is the list of HTTP headers other than the simple
1849 // response headers to give permission for the user-agent to share
1850 // across domains.
1851 ResponseHeaders []<a href="https://pkg.go.dev/builtin#string">string</a>
1852 }
1853 - uid: cloud.google.com/go/storage.Client
1854 name: Client
1855 id: Client
1856 summary: |
1857 Client is a client for interacting with Google Cloud Storage.
1858
1859 Clients should be reused instead of created as needed.
1860 The methods of Client are safe for concurrent use by multiple goroutines.
1861 parent: cloud.google.com/go/storage
1862 type: type
1863 langs:
1864 - go
1865 syntax:
1866 content: |-
1867 type Client struct {
1868 // contains filtered or unexported fields
1869 }
1870 - uid: cloud.google.com/go/storage.Client.NewClient
1871 name: |
1872 func NewClient
1873 id: NewClient
1874 summary: |
1875 NewClient creates a new Google Cloud Storage client using the HTTP transport.
1876 The default scope is ScopeFullControl. To use a different scope, like
1877 ScopeReadOnly, use option.WithScopes.
1878
1879 Clients should be reused instead of created as needed. The methods of Client
1880 are safe for concurrent use by multiple goroutines.
1881
1882 You may configure the client by passing in options from the [google.golang.org/api/option]
1883 package. You may also use options defined in this package, such as [WithJSONReads].
1884 parent: cloud.google.com/go/storage.Client
1885 type: function
1886 langs:
1887 - go
1888 syntax:
1889 content: func NewClient(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, opts ...<a href="https://pkg.go.dev/google.golang.org/api/option">option</a>.<a href="https://pkg.go.dev/google.golang.org/api/option#ClientOption">ClientOption</a>) (*<a href="#cloud_google_com_go_storage_Client">Client</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)
1890 codeexamples:
1891 - content: |
1892 package main
1893
1894 import (
1895 "context"
1896
1897 "cloud.google.com/go/storage"
1898 )
1899
1900 func main() {
1901 ctx := context.Background()
1902 // Use Google Application Default Credentials to authorize and authenticate the client.
1903 // More information about Application Default Credentials and how to enable is at
1904 // https://developers.google.com/identity/protocols/application-default-credentials.
1905 client, err := storage.NewClient(ctx)
1906 if err != nil {
1907 // TODO: handle error.
1908 }
1909 // Use the client.
1910
1911 // Close the client when finished.
1912 if err := client.Close(); err != nil {
1913 // TODO: handle error.
1914 }
1915 }
1916 - content: |
1917 package main
1918
1919 import (
1920 "context"
1921
1922 "cloud.google.com/go/storage"
1923 "google.golang.org/api/option"
1924 )
1925
1926 func main() {
1927 ctx := context.Background()
1928 client, err := storage.NewClient(ctx, option.WithoutAuthentication())
1929 if err != nil {
1930 // TODO: handle error.
1931 }
1932 // Use the client.
1933
1934 // Close the client when finished.
1935 if err := client.Close(); err != nil {
1936 // TODO: handle error.
1937 }
1938 }
1939 name: unauthenticated
1940 - uid: cloud.google.com/go/storage.Client.NewGRPCClient
1941 name: |
1942 func NewGRPCClient
1943 id: NewGRPCClient
1944 summary: |
1945 NewGRPCClient creates a new Storage client using the gRPC transport and API.
1946 Client methods which have not been implemented in gRPC will return an error.
1947 In particular, methods for Cloud Pub/Sub notifications are not supported.
1948
1949 The storage gRPC API is still in preview and not yet publicly available.
1950 If you would like to use the API, please first contact your GCP account rep to
1951 request access. The API may be subject to breaking changes.
1952
1953 Clients should be reused instead of created as needed. The methods of Client
1954 are safe for concurrent use by multiple goroutines.
1955
1956 You may configure the client by passing in options from the [google.golang.org/api/option]
1957 package.
1958 parent: cloud.google.com/go/storage.Client
1959 type: function
1960 langs:
1961 - go
1962 syntax:
1963 content: func NewGRPCClient(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, opts ...<a href="https://pkg.go.dev/google.golang.org/api/option">option</a>.<a href="https://pkg.go.dev/google.golang.org/api/option#ClientOption">ClientOption</a>) (*<a href="#cloud_google_com_go_storage_Client">Client</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)
1964 - uid: cloud.google.com/go/storage.Client.Bucket
1965 name: |
1966 func (*Client) Bucket
1967 id: Bucket
1968 summary: |
1969 Bucket returns a BucketHandle, which provides operations on the named bucket.
1970 This call does not perform any network operations.
1971
1972 The supplied name must contain only lowercase letters, numbers, dashes,
1973 underscores, and dots. The full specification for valid bucket names can be
1974 found at:
1975
1976 https://cloud.google.com/storage/docs/bucket-naming
1977 parent: cloud.google.com/go/storage.Client
1978 type: method
1979 langs:
1980 - go
1981 syntax:
1982 content: func (c *<a href="#cloud_google_com_go_storage_Client">Client</a>) Bucket(name <a href="https://pkg.go.dev/builtin#string">string</a>) *<a href="#cloud_google_com_go_storage_BucketHandle">BucketHandle</a>
1983 - uid: cloud.google.com/go/storage.Client.Buckets
1984 name: |
1985 func (*Client) Buckets
1986 id: Buckets
1987 summary: |
1988 Buckets returns an iterator over the buckets in the project. You may
1989 optionally set the iterator's Prefix field to restrict the list to buckets
1990 whose names begin with the prefix. By default, all buckets in the project
1991 are returned.
1992
1993 Note: The returned iterator is not safe for concurrent operations without explicit synchronization.
1994 parent: cloud.google.com/go/storage.Client
1995 type: method
1996 langs:
1997 - go
1998 syntax:
1999 content: func (c *<a href="#cloud_google_com_go_storage_Client">Client</a>) Buckets(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, projectID <a href="https://pkg.go.dev/builtin#string">string</a>) *<a href="#cloud_google_com_go_storage_BucketIterator">BucketIterator</a>
2000 codeexamples:
2001 - content: |
2002 package main
2003
2004 import (
2005 "context"
2006
2007 "cloud.google.com/go/storage"
2008 )
2009
2010 func main() {
2011 ctx := context.Background()
2012 client, err := storage.NewClient(ctx)
2013 if err != nil {
2014 // TODO: handle error.
2015 }
2016 it := client.Buckets(ctx, "my-project")
2017 _ = it // TODO: iterate using Next or iterator.Pager.
2018 }
2019 - uid: cloud.google.com/go/storage.Client.Close
2020 name: |
2021 func (*Client) Close
2022 id: Close
2023 summary: |
2024 Close closes the Client.
2025
2026 Close need not be called at program exit.
2027 parent: cloud.google.com/go/storage.Client
2028 type: method
2029 langs:
2030 - go
2031 syntax:
2032 content: func (c *<a href="#cloud_google_com_go_storage_Client">Client</a>) Close() <a href="https://pkg.go.dev/builtin#error">error</a>
2033 - uid: cloud.google.com/go/storage.Client.CreateHMACKey
2034 name: |
2035 func (*Client) CreateHMACKey
2036 id: CreateHMACKey
2037 summary: |
2038 CreateHMACKey invokes an RPC for Google Cloud Storage to create a new HMACKey.
2039 parent: cloud.google.com/go/storage.Client
2040 type: method
2041 langs:
2042 - go
2043 syntax:
2044 content: func (c *<a href="#cloud_google_com_go_storage_Client">Client</a>) CreateHMACKey(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, projectID, serviceAccountEmail <a href="https://pkg.go.dev/builtin#string">string</a>, opts ...<a href="#cloud_google_com_go_storage_HMACKeyOption">HMACKeyOption</a>) (*<a href="#cloud_google_com_go_storage_HMACKey">HMACKey</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)
2045 codeexamples:
2046 - content: |
2047 package main
2048
2049 import (
2050 "context"
2051
2052 "cloud.google.com/go/storage"
2053 )
2054
2055 func main() {
2056 ctx := context.Background()
2057 client, err := storage.NewClient(ctx)
2058 if err != nil {
2059 // TODO: handle error.
2060 }
2061
2062 hkey, err := client.CreateHMACKey(ctx, "project-id", "service-account-email")
2063 if err != nil {
2064 // TODO: handle error.
2065 }
2066 _ = hkey // TODO: Use the HMAC Key.
2067 }
2068 - uid: cloud.google.com/go/storage.Client.HMACKeyHandle
2069 name: |
2070 func (*Client) HMACKeyHandle
2071 id: HMACKeyHandle
2072 summary: |
2073 HMACKeyHandle creates a handle that will be used for HMACKey operations.
2074 parent: cloud.google.com/go/storage.Client
2075 type: method
2076 langs:
2077 - go
2078 syntax:
2079 content: func (c *<a href="#cloud_google_com_go_storage_Client">Client</a>) HMACKeyHandle(projectID, accessID <a href="https://pkg.go.dev/builtin#string">string</a>) *<a href="#cloud_google_com_go_storage_HMACKeyHandle">HMACKeyHandle</a>
2080 - uid: cloud.google.com/go/storage.Client.ListHMACKeys
2081 name: |
2082 func (*Client) ListHMACKeys
2083 id: ListHMACKeys
2084 summary: |
2085 ListHMACKeys returns an iterator for listing HMACKeys.
2086
2087 Note: This iterator is not safe for concurrent operations without explicit synchronization.
2088 parent: cloud.google.com/go/storage.Client
2089 type: method
2090 langs:
2091 - go
2092 syntax:
2093 content: func (c *<a href="#cloud_google_com_go_storage_Client">Client</a>) ListHMACKeys(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, projectID <a href="https://pkg.go.dev/builtin#string">string</a>, opts ...<a href="#cloud_google_com_go_storage_HMACKeyOption">HMACKeyOption</a>) *<a href="#cloud_google_com_go_storage_HMACKeysIterator">HMACKeysIterator</a>
2094 codeexamples:
2095 - content: |
2096 package main
2097
2098 import (
2099 "context"
2100
2101 "cloud.google.com/go/storage"
2102 "google.golang.org/api/iterator"
2103 )
2104
2105 func main() {
2106 ctx := context.Background()
2107 client, err := storage.NewClient(ctx)
2108 if err != nil {
2109 // TODO: handle error.
2110 }
2111
2112 iter := client.ListHMACKeys(ctx, "project-id")
2113 for {
2114 key, err := iter.Next()
2115 if err == iterator.Done {
2116 break
2117 }
2118 if err != nil {
2119 // TODO: handle error.
2120 }
2121 _ = key // TODO: Use the key.
2122 }
2123 }
2124 - content: |
2125 package main
2126
2127 import (
2128 "context"
2129
2130 "cloud.google.com/go/storage"
2131 "google.golang.org/api/iterator"
2132 )
2133
2134 func main() {
2135 ctx := context.Background()
2136 client, err := storage.NewClient(ctx)
2137 if err != nil {
2138 // TODO: handle error.
2139 }
2140
2141 iter := client.ListHMACKeys(ctx, "project-id", storage.ForHMACKeyServiceAccountEmail("[email protected]"))
2142 for {
2143 key, err := iter.Next()
2144 if err == iterator.Done {
2145 break
2146 }
2147 if err != nil {
2148 // TODO: handle error.
2149 }
2150 _ = key // TODO: Use the key.
2151 }
2152 }
2153 name: forServiceAccountEmail
2154 - content: |
2155 package main
2156
2157 import (
2158 "context"
2159
2160 "cloud.google.com/go/storage"
2161 "google.golang.org/api/iterator"
2162 )
2163
2164 func main() {
2165 ctx := context.Background()
2166 client, err := storage.NewClient(ctx)
2167 if err != nil {
2168 // TODO: handle error.
2169 }
2170
2171 iter := client.ListHMACKeys(ctx, "project-id", storage.ShowDeletedHMACKeys())
2172 for {
2173 key, err := iter.Next()
2174 if err == iterator.Done {
2175 break
2176 }
2177 if err != nil {
2178 // TODO: handle error.
2179 }
2180 _ = key // TODO: Use the key.
2181 }
2182 }
2183 name: showDeletedKeys
2184 - uid: cloud.google.com/go/storage.Client.ServiceAccount
2185 name: |
2186 func (*Client) ServiceAccount
2187 id: ServiceAccount
2188 summary: |
2189 ServiceAccount fetches the email address of the given project's Google Cloud Storage service account.
2190 parent: cloud.google.com/go/storage.Client
2191 type: method
2192 langs:
2193 - go
2194 syntax:
2195 content: func (c *<a href="#cloud_google_com_go_storage_Client">Client</a>) ServiceAccount(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, projectID <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/builtin#string">string</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)
2196 - uid: cloud.google.com/go/storage.Client.SetRetry
2197 name: |
2198 func (*Client) SetRetry
2199 id: SetRetry
2200 summary: |
2201 SetRetry configures the client with custom retry behavior as specified by the
2202 options that are passed to it. All operations using this client will use the
2203 customized retry configuration.
2204 This should be called once before using the client for network operations, as
2205 there could be indeterminate behaviour with operations in progress.
2206 Retry options set on a bucket or object handle will take precedence over
2207 these options.
2208 parent: cloud.google.com/go/storage.Client
2209 type: method
2210 langs:
2211 - go
2212 syntax:
2213 content: func (c *<a href="#cloud_google_com_go_storage_Client">Client</a>) SetRetry(opts ...<a href="#cloud_google_com_go_storage_RetryOption">RetryOption</a>)
2214 - uid: cloud.google.com/go/storage.Composer
2215 name: Composer
2216 id: Composer
2217 summary: |
2218 A Composer composes source objects into a destination object.
2219
2220 For Requester Pays buckets, the user project of dst is billed.
2221 parent: cloud.google.com/go/storage
2222 type: type
2223 langs:
2224 - go
2225 syntax:
2226 content: |-
2227 type Composer struct {
2228 // ObjectAttrs are optional attributes to set on the destination object.
2229 // Any attributes must be initialized before any calls on the Composer. Nil
2230 // or zero-valued attributes are ignored.
2231 <a href="#cloud_google_com_go_storage_ObjectAttrs">ObjectAttrs</a>
2232
2233 // SendCRC specifies whether to transmit a CRC32C field. It should be set
2234 // to true in addition to setting the Composer's CRC32C field, because zero
2235 // is a valid CRC and normally a zero would not be transmitted.
2236 // If a CRC32C is sent, and the data in the destination object does not match
2237 // the checksum, the compose will be rejected.
2238 SendCRC32C <a href="https://pkg.go.dev/builtin#bool">bool</a>
2239 // contains filtered or unexported fields
2240 }
2241 - uid: cloud.google.com/go/storage.Composer.Run
2242 name: |
2243 func (*Composer) Run
2244 id: Run
2245 summary: |
2246 Run performs the compose operation.
2247 parent: cloud.google.com/go/storage.Composer
2248 type: method
2249 langs:
2250 - go
2251 syntax:
2252 content: func (c *<a href="#cloud_google_com_go_storage_Composer">Composer</a>) Run(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) (attrs *<a href="#cloud_google_com_go_storage_ObjectAttrs">ObjectAttrs</a>, err <a href="https://pkg.go.dev/builtin#error">error</a>)
2253 codeexamples:
2254 - content: |
2255 package main
2256
2257 import (
2258 "context"
2259 "fmt"
2260
2261 "cloud.google.com/go/storage"
2262 )
2263
2264 func main() {
2265 ctx := context.Background()
2266 client, err := storage.NewClient(ctx)
2267 if err != nil {
2268 // TODO: handle error.
2269 }
2270 bkt := client.Bucket("bucketname")
2271 src1 := bkt.Object("o1")
2272 src2 := bkt.Object("o2")
2273 dst := bkt.Object("o3")
2274
2275 // Compose and modify metadata.
2276 c := dst.ComposerFrom(src1, src2)
2277 c.ContentType = "text/plain"
2278
2279 // Set the expected checksum for the destination object to be validated by
2280 // the backend (if desired).
2281 c.CRC32C = 42
2282 c.SendCRC32C = true
2283
2284 attrs, err := c.Run(ctx)
2285 if err != nil {
2286 // TODO: Handle error.
2287 }
2288 fmt.Println(attrs)
2289 // Just compose.
2290 attrs, err = dst.ComposerFrom(src1, src2).Run(ctx)
2291 if err != nil {
2292 // TODO: Handle error.
2293 }
2294 fmt.Println(attrs)
2295 }
2296 - uid: cloud.google.com/go/storage.Conditions
2297 name: Conditions
2298 id: Conditions
2299 summary: |
2300 Conditions constrain methods to act on specific generations of
2301 objects.
2302
2303 The zero value is an empty set of constraints. Not all conditions or
2304 combinations of conditions are applicable to all methods.
2305 See https://cloud.google.com/storage/docs/generations-preconditions
2306 for details on how these operate.
2307 parent: cloud.google.com/go/storage
2308 type: type
2309 langs:
2310 - go
2311 syntax:
2312 content: |-
2313 type Conditions struct {
2314
2315 // GenerationMatch specifies that the object must have the given generation
2316 // for the operation to occur.
2317 // If GenerationMatch is zero, it has no effect.
2318 // Use DoesNotExist to specify that the object does not exist in the bucket.
2319 GenerationMatch <a href="https://pkg.go.dev/builtin#int64">int64</a>
2320
2321 // GenerationNotMatch specifies that the object must not have the given
2322 // generation for the operation to occur.
2323 // If GenerationNotMatch is zero, it has no effect.
2324 // This condition only works for object reads if the WithJSONReads client
2325 // option is set.
2326 GenerationNotMatch <a href="https://pkg.go.dev/builtin#int64">int64</a>
2327
2328 // DoesNotExist specifies that the object must not exist in the bucket for
2329 // the operation to occur.
2330 // If DoesNotExist is false, it has no effect.
2331 DoesNotExist <a href="https://pkg.go.dev/builtin#bool">bool</a>
2332
2333 // MetagenerationMatch specifies that the object must have the given
2334 // metageneration for the operation to occur.
2335 // If MetagenerationMatch is zero, it has no effect.
2336 MetagenerationMatch <a href="https://pkg.go.dev/builtin#int64">int64</a>
2337
2338 // MetagenerationNotMatch specifies that the object must not have the given
2339 // metageneration for the operation to occur.
2340 // If MetagenerationNotMatch is zero, it has no effect.
2341 // This condition only works for object reads if the WithJSONReads client
2342 // option is set.
2343 MetagenerationNotMatch <a href="https://pkg.go.dev/builtin#int64">int64</a>
2344 }
2345 - uid: cloud.google.com/go/storage.Copier
2346 name: Copier
2347 id: Copier
2348 summary: |
2349 A Copier copies a source object to a destination.
2350 parent: cloud.google.com/go/storage
2351 type: type
2352 langs:
2353 - go
2354 syntax:
2355 content: |-
2356 type Copier struct {
2357 // ObjectAttrs are optional attributes to set on the destination object.
2358 // Any attributes must be initialized before any calls on the Copier. Nil
2359 // or zero-valued attributes are ignored.
2360 <a href="#cloud_google_com_go_storage_ObjectAttrs">ObjectAttrs</a>
2361
2362 // RewriteToken can be set before calling Run to resume a copy
2363 // operation. After Run returns a non-nil error, RewriteToken will
2364 // have been updated to contain the value needed to resume the copy.
2365 RewriteToken <a href="https://pkg.go.dev/builtin#string">string</a>
2366
2367 // ProgressFunc can be used to monitor the progress of a multi-RPC copy
2368 // operation. If ProgressFunc is not nil and copying requires multiple
2369 // calls to the underlying service (see
2370 // https://cloud.google.com/storage/docs/json_api/v1/objects/rewrite), then
2371 // ProgressFunc will be invoked after each call with the number of bytes of
2372 // content copied so far and the total size in bytes of the source object.
2373 //
2374 // ProgressFunc is intended to make upload progress available to the
2375 // application. For example, the implementation of ProgressFunc may update
2376 // a progress bar in the application's UI, or log the result of
2377 // float64(copiedBytes)/float64(totalBytes).
2378 //
2379 // ProgressFunc should return quickly without blocking.
2380 ProgressFunc func(copiedBytes, totalBytes <a href="https://pkg.go.dev/builtin#uint64">uint64</a>)
2381
2382 // The Cloud KMS key, in the form projects/P/locations/L/keyRings/R/cryptoKeys/K,
2383 // that will be used to encrypt the object. Overrides the object's KMSKeyName, if
2384 // any.
2385 //
2386 // Providing both a DestinationKMSKeyName and a customer-supplied encryption key
2387 // (via ObjectHandle.Key) on the destination object will result in an error when
2388 // Run is called.
2389 DestinationKMSKeyName <a href="https://pkg.go.dev/builtin#string">string</a>
2390 // contains filtered or unexported fields
2391 }
2392 - uid: cloud.google.com/go/storage.Copier.Run
2393 name: |
2394 func (*Copier) Run
2395 id: Run
2396 summary: |
2397 Run performs the copy.
2398 parent: cloud.google.com/go/storage.Copier
2399 type: method
2400 langs:
2401 - go
2402 syntax:
2403 content: func (c *<a href="#cloud_google_com_go_storage_Copier">Copier</a>) Run(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) (attrs *<a href="#cloud_google_com_go_storage_ObjectAttrs">ObjectAttrs</a>, err <a href="https://pkg.go.dev/builtin#error">error</a>)
2404 codeexamples:
2405 - content: |
2406 package main
2407
2408 import (
2409 "context"
2410 "fmt"
2411
2412 "cloud.google.com/go/storage"
2413 )
2414
2415 func main() {
2416 ctx := context.Background()
2417 client, err := storage.NewClient(ctx)
2418 if err != nil {
2419 // TODO: handle error.
2420 }
2421 src := client.Bucket("bucketname").Object("file1")
2422 dst := client.Bucket("another-bucketname").Object("file2")
2423
2424 // Copy content and modify metadata.
2425 copier := dst.CopierFrom(src)
2426 copier.ContentType = "text/plain"
2427 attrs, err := copier.Run(ctx)
2428 if err != nil {
2429 // TODO: Handle error, possibly resuming with copier.RewriteToken.
2430 }
2431 fmt.Println(attrs)
2432
2433 // Just copy content.
2434 attrs, err = dst.CopierFrom(src).Run(ctx)
2435 if err != nil {
2436 // TODO: Handle error. No way to resume.
2437 }
2438 fmt.Println(attrs)
2439 }
2440 - content: |
2441 package main
2442
2443 import (
2444 "context"
2445 "log"
2446
2447 "cloud.google.com/go/storage"
2448 )
2449
2450 func main() {
2451 // Display progress across multiple rewrite RPCs.
2452 ctx := context.Background()
2453 client, err := storage.NewClient(ctx)
2454 if err != nil {
2455 // TODO: handle error.
2456 }
2457 src := client.Bucket("bucketname").Object("file1")
2458 dst := client.Bucket("another-bucketname").Object("file2")
2459
2460 copier := dst.CopierFrom(src)
2461 copier.ProgressFunc = func(copiedBytes, totalBytes uint64) {
2462 log.Printf("copy %.1f%% done", float64(copiedBytes)/float64(totalBytes)*100)
2463 }
2464 if _, err := copier.Run(ctx); err != nil {
2465 // TODO: handle error.
2466 }
2467 }
2468 name: progress
2469 - uid: cloud.google.com/go/storage.CustomPlacementConfig
2470 name: CustomPlacementConfig
2471 id: CustomPlacementConfig
2472 summary: |
2473 CustomPlacementConfig holds the bucket's custom placement
2474 configuration for Custom Dual Regions. See
2475 https://cloud.google.com/storage/docs/locations#location-dr for more information.
2476 parent: cloud.google.com/go/storage
2477 type: type
2478 langs:
2479 - go
2480 syntax:
2481 content: |-
2482 type CustomPlacementConfig struct {
2483 // The list of regional locations in which data is placed.
2484 // Custom Dual Regions require exactly 2 regional locations.
2485 DataLocations []<a href="https://pkg.go.dev/builtin#string">string</a>
2486 }
2487 - uid: cloud.google.com/go/storage.HMACKey
2488 name: HMACKey
2489 id: HMACKey
2490 summary: |
2491 HMACKey is the representation of a Google Cloud Storage HMAC key.
2492
2493 HMAC keys are used to authenticate signed access to objects. To enable HMAC key
2494 authentication, please visit https://cloud.google.com/storage/docs/migrating.
2495 parent: cloud.google.com/go/storage
2496 type: type
2497 langs:
2498 - go
2499 syntax:
2500 content: |-
2501 type HMACKey struct {
2502 // The HMAC's secret key.
2503 Secret <a href="https://pkg.go.dev/builtin#string">string</a>
2504
2505 // AccessID is the ID of the HMAC key.
2506 AccessID <a href="https://pkg.go.dev/builtin#string">string</a>
2507
2508 // Etag is the HTTP/1.1 Entity tag.
2509 Etag <a href="https://pkg.go.dev/builtin#string">string</a>
2510
2511 // ID is the ID of the HMAC key, including the ProjectID and AccessID.
2512 ID <a href="https://pkg.go.dev/builtin#string">string</a>
2513
2514 // ProjectID is the ID of the project that owns the
2515 // service account to which the key authenticates.
2516 ProjectID <a href="https://pkg.go.dev/builtin#string">string</a>
2517
2518 // ServiceAccountEmail is the email address
2519 // of the key's associated service account.
2520 ServiceAccountEmail <a href="https://pkg.go.dev/builtin#string">string</a>
2521
2522 // CreatedTime is the creation time of the HMAC key.
2523 CreatedTime <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Time">Time</a>
2524
2525 // UpdatedTime is the last modification time of the HMAC key metadata.
2526 UpdatedTime <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Time">Time</a>
2527
2528 // State is the state of the HMAC key.
2529 // It can be one of StateActive, StateInactive or StateDeleted.
2530 State <a href="#cloud_google_com_go_storage_HMACState">HMACState</a>
2531 }
2532 - uid: cloud.google.com/go/storage.HMACKeyAttrsToUpdate
2533 name: HMACKeyAttrsToUpdate
2534 id: HMACKeyAttrsToUpdate
2535 summary: |
2536 HMACKeyAttrsToUpdate defines the attributes of an HMACKey that will be updated.
2537 parent: cloud.google.com/go/storage
2538 type: type
2539 langs:
2540 - go
2541 syntax:
2542 content: |-
2543 type HMACKeyAttrsToUpdate struct {
2544 // State is required and must be either StateActive or StateInactive.
2545 State <a href="#cloud_google_com_go_storage_HMACState">HMACState</a>
2546
2547 // Etag is an optional field and it is the HTTP/1.1 Entity tag.
2548 Etag <a href="https://pkg.go.dev/builtin#string">string</a>
2549 }
2550 - uid: cloud.google.com/go/storage.HMACKeyHandle
2551 name: HMACKeyHandle
2552 id: HMACKeyHandle
2553 summary: |
2554 HMACKeyHandle helps provide access and management for HMAC keys.
2555 parent: cloud.google.com/go/storage
2556 type: type
2557 langs:
2558 - go
2559 syntax:
2560 content: |-
2561 type HMACKeyHandle struct {
2562 // contains filtered or unexported fields
2563 }
2564 - uid: cloud.google.com/go/storage.HMACKeyHandle.Delete
2565 name: |
2566 func (*HMACKeyHandle) Delete
2567 id: Delete
2568 summary: |
2569 Delete invokes an RPC to delete the key referenced by accessID, on Google Cloud Storage.
2570 Only inactive HMAC keys can be deleted.
2571 After deletion, a key cannot be used to authenticate requests.
2572 parent: cloud.google.com/go/storage.HMACKeyHandle
2573 type: method
2574 langs:
2575 - go
2576 syntax:
2577 content: func (hkh *<a href="#cloud_google_com_go_storage_HMACKeyHandle">HMACKeyHandle</a>) Delete(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, opts ...<a href="#cloud_google_com_go_storage_HMACKeyOption">HMACKeyOption</a>) <a href="https://pkg.go.dev/builtin#error">error</a>
2578 codeexamples:
2579 - content: |
2580 package main
2581
2582 import (
2583 "context"
2584
2585 "cloud.google.com/go/storage"
2586 )
2587
2588 func main() {
2589 ctx := context.Background()
2590 client, err := storage.NewClient(ctx)
2591 if err != nil {
2592 // TODO: handle error.
2593 }
2594
2595 hkh := client.HMACKeyHandle("project-id", "access-key-id")
2596 // Make sure that the HMACKey being deleted has a status of inactive.
2597 if err := hkh.Delete(ctx); err != nil {
2598 // TODO: handle error.
2599 }
2600 }
2601 - uid: cloud.google.com/go/storage.HMACKeyHandle.Get
2602 name: |
2603 func (*HMACKeyHandle) Get
2604 id: Get
2605 summary: |
2606 Get invokes an RPC to retrieve the HMAC key referenced by the
2607 HMACKeyHandle's accessID.
2608
2609 Options such as UserProjectForHMACKeys can be used to set the
2610 userProject to be billed against for operations.
2611 parent: cloud.google.com/go/storage.HMACKeyHandle
2612 type: method
2613 langs:
2614 - go
2615 syntax:
2616 content: func (hkh *<a href="#cloud_google_com_go_storage_HMACKeyHandle">HMACKeyHandle</a>) Get(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, opts ...<a href="#cloud_google_com_go_storage_HMACKeyOption">HMACKeyOption</a>) (*<a href="#cloud_google_com_go_storage_HMACKey">HMACKey</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)
2617 codeexamples:
2618 - content: |
2619 package main
2620
2621 import (
2622 "context"
2623
2624 "cloud.google.com/go/storage"
2625 )
2626
2627 func main() {
2628 ctx := context.Background()
2629 client, err := storage.NewClient(ctx)
2630 if err != nil {
2631 // TODO: handle error.
2632 }
2633
2634 hkh := client.HMACKeyHandle("project-id", "access-key-id")
2635 hkey, err := hkh.Get(ctx)
2636 if err != nil {
2637 // TODO: handle error.
2638 }
2639 _ = hkey // TODO: Use the HMAC Key.
2640 }
2641 - uid: cloud.google.com/go/storage.HMACKeyHandle.Update
2642 name: |
2643 func (*HMACKeyHandle) Update
2644 id: Update
2645 summary: |
2646 Update mutates the HMACKey referred to by accessID.
2647 parent: cloud.google.com/go/storage.HMACKeyHandle
2648 type: method
2649 langs:
2650 - go
2651 syntax:
2652 content: func (h *<a href="#cloud_google_com_go_storage_HMACKeyHandle">HMACKeyHandle</a>) Update(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, au <a href="#cloud_google_com_go_storage_HMACKeyAttrsToUpdate">HMACKeyAttrsToUpdate</a>, opts ...<a href="#cloud_google_com_go_storage_HMACKeyOption">HMACKeyOption</a>) (*<a href="#cloud_google_com_go_storage_HMACKey">HMACKey</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)
2653 codeexamples:
2654 - content: |
2655 package main
2656
2657 import (
2658 "context"
2659
2660 "cloud.google.com/go/storage"
2661 )
2662
2663 func main() {
2664 ctx := context.Background()
2665 client, err := storage.NewClient(ctx)
2666 if err != nil {
2667 // TODO: handle error.
2668 }
2669
2670 hkh := client.HMACKeyHandle("project-id", "access-key-id")
2671 ukey, err := hkh.Update(ctx, storage.HMACKeyAttrsToUpdate{
2672 State: storage.Inactive,
2673 })
2674 if err != nil {
2675 // TODO: handle error.
2676 }
2677 _ = ukey // TODO: Use the HMAC Key.
2678 }
2679 - uid: cloud.google.com/go/storage.HMACKeyOption
2680 name: HMACKeyOption
2681 id: HMACKeyOption
2682 summary: |
2683 HMACKeyOption configures the behavior of HMACKey related methods and actions.
2684 parent: cloud.google.com/go/storage
2685 type: type
2686 langs:
2687 - go
2688 syntax:
2689 content: |-
2690 type HMACKeyOption interface {
2691 // contains filtered or unexported methods
2692 }
2693 - uid: cloud.google.com/go/storage.HMACKeyOption.ForHMACKeyServiceAccountEmail
2694 name: |
2695 func ForHMACKeyServiceAccountEmail
2696 id: ForHMACKeyServiceAccountEmail
2697 summary: |
2698 ForHMACKeyServiceAccountEmail returns HMAC Keys that are
2699 associated with the email address of a service account in the project.
2700
2701 Only one service account email can be used as a filter, so if multiple
2702 of these options are applied, the last email to be set will be used.
2703 parent: cloud.google.com/go/storage.HMACKeyOption
2704 type: function
2705 langs:
2706 - go
2707 syntax:
2708 content: func ForHMACKeyServiceAccountEmail(serviceAccountEmail <a href="https://pkg.go.dev/builtin#string">string</a>) <a href="#cloud_google_com_go_storage_HMACKeyOption">HMACKeyOption</a>
2709 - uid: cloud.google.com/go/storage.HMACKeyOption.ShowDeletedHMACKeys
2710 name: |
2711 func ShowDeletedHMACKeys
2712 id: ShowDeletedHMACKeys
2713 summary: |
2714 ShowDeletedHMACKeys will also list keys whose state is "DELETED".
2715 parent: cloud.google.com/go/storage.HMACKeyOption
2716 type: function
2717 langs:
2718 - go
2719 syntax:
2720 content: func ShowDeletedHMACKeys() <a href="#cloud_google_com_go_storage_HMACKeyOption">HMACKeyOption</a>
2721 - uid: cloud.google.com/go/storage.HMACKeyOption.UserProjectForHMACKeys
2722 name: |
2723 func UserProjectForHMACKeys
2724 id: UserProjectForHMACKeys
2725 summary: |
2726 UserProjectForHMACKeys will bill the request against userProjectID
2727 if userProjectID is non-empty.
2728
2729 Note: This is a noop right now and only provided for API compatibility.
2730 parent: cloud.google.com/go/storage.HMACKeyOption
2731 type: function
2732 langs:
2733 - go
2734 syntax:
2735 content: func UserProjectForHMACKeys(userProjectID <a href="https://pkg.go.dev/builtin#string">string</a>) <a href="#cloud_google_com_go_storage_HMACKeyOption">HMACKeyOption</a>
2736 - uid: cloud.google.com/go/storage.HMACKeysIterator
2737 name: HMACKeysIterator
2738 id: HMACKeysIterator
2739 summary: |
2740 An HMACKeysIterator is an iterator over HMACKeys.
2741
2742 Note: This iterator is not safe for concurrent operations without explicit synchronization.
2743 parent: cloud.google.com/go/storage
2744 type: type
2745 langs:
2746 - go
2747 syntax:
2748 content: |-
2749 type HMACKeysIterator struct {
2750 // contains filtered or unexported fields
2751 }
2752 - uid: cloud.google.com/go/storage.HMACKeysIterator.Next
2753 name: |
2754 func (*HMACKeysIterator) Next
2755 id: Next
2756 summary: |
2757 Next returns the next result. Its second return value is iterator.Done if
2758 there are no more results. Once Next returns iterator.Done, all subsequent
2759 calls will return iterator.Done.
2760
2761 Note: This iterator is not safe for concurrent operations without explicit synchronization.
2762 parent: cloud.google.com/go/storage.HMACKeysIterator
2763 type: method
2764 langs:
2765 - go
2766 syntax:
2767 content: func (it *<a href="#cloud_google_com_go_storage_HMACKeysIterator">HMACKeysIterator</a>) Next() (*<a href="#cloud_google_com_go_storage_HMACKey">HMACKey</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)
2768 - uid: cloud.google.com/go/storage.HMACKeysIterator.PageInfo
2769 name: |
2770 func (*HMACKeysIterator) PageInfo
2771 id: PageInfo
2772 summary: |
2773 PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
2774
2775 Note: This iterator is not safe for concurrent operations without explicit synchronization.
2776 parent: cloud.google.com/go/storage.HMACKeysIterator
2777 type: method
2778 langs:
2779 - go
2780 syntax:
2781 content: func (it *<a href="#cloud_google_com_go_storage_HMACKeysIterator">HMACKeysIterator</a>) PageInfo() *<a href="https://pkg.go.dev/google.golang.org/api/iterator">iterator</a>.<a href="https://pkg.go.dev/google.golang.org/api/iterator#PageInfo">PageInfo</a>
2782 - uid: cloud.google.com/go/storage.HMACState
2783 name: HMACState
2784 id: HMACState
2785 summary: |
2786 HMACState is the state of the HMAC key.
2787 parent: cloud.google.com/go/storage
2788 type: type
2789 langs:
2790 - go
2791 syntax:
2792 content: type HMACState <a href="https://pkg.go.dev/builtin#string">string</a>
2793 - uid: cloud.google.com/go/storage.Active,Inactive,Deleted
2794 name: Active, Inactive, Deleted
2795 id: Active,Inactive,Deleted
2796 parent: cloud.google.com/go/storage.HMACState
2797 type: const
2798 langs:
2799 - go
2800 syntax:
2801 content: |-
2802 const (
2803 // Active is the status for an active key that can be used to sign
2804 // requests.
2805 Active <a href="#cloud_google_com_go_storage_HMACState">HMACState</a> = "ACTIVE"
2806
2807 // Inactive is the status for an inactive key thus requests signed by
2808 // this key will be denied.
2809 Inactive <a href="#cloud_google_com_go_storage_HMACState">HMACState</a> = "INACTIVE"
2810
2811 // Deleted is the status for a key that is deleted.
2812 // Once in this state the key cannot key cannot be recovered
2813 // and does not count towards key limits. Deleted keys will be cleaned
2814 // up later.
2815 Deleted <a href="#cloud_google_com_go_storage_HMACState">HMACState</a> = "DELETED"
2816 )
2817 - uid: cloud.google.com/go/storage.Lifecycle
2818 name: Lifecycle
2819 id: Lifecycle
2820 summary: |
2821 Lifecycle is the lifecycle configuration for objects in the bucket.
2822 parent: cloud.google.com/go/storage
2823 type: type
2824 langs:
2825 - go
2826 syntax:
2827 content: |-
2828 type Lifecycle struct {
2829 Rules []<a href="#cloud_google_com_go_storage_LifecycleRule">LifecycleRule</a>
2830 }
2831 - uid: cloud.google.com/go/storage.LifecycleAction
2832 name: LifecycleAction
2833 id: LifecycleAction
2834 summary: |
2835 LifecycleAction is a lifecycle configuration action.
2836 parent: cloud.google.com/go/storage
2837 type: type
2838 langs:
2839 - go
2840 syntax:
2841 content: |-
2842 type LifecycleAction struct {
2843 // Type is the type of action to take on matching objects.
2844 //
2845 // Acceptable values are storage.DeleteAction, storage.SetStorageClassAction,
2846 // and storage.AbortIncompleteMPUAction.
2847 Type <a href="https://pkg.go.dev/builtin#string">string</a>
2848
2849 // StorageClass is the storage class to set on matching objects if the Action
2850 // is "SetStorageClass".
2851 StorageClass <a href="https://pkg.go.dev/builtin#string">string</a>
2852 }
2853 - uid: cloud.google.com/go/storage.LifecycleCondition
2854 name: LifecycleCondition
2855 id: LifecycleCondition
2856 summary: |
2857 LifecycleCondition is a set of conditions used to match objects and take an
2858 action automatically.
2859
2860 All configured conditions must be met for the associated action to be taken.
2861 parent: cloud.google.com/go/storage
2862 type: type
2863 langs:
2864 - go
2865 syntax:
2866 content: |-
2867 type LifecycleCondition struct {
2868 // AllObjects is used to select all objects in a bucket by
2869 // setting AgeInDays to 0.
2870 AllObjects <a href="https://pkg.go.dev/builtin#bool">bool</a>
2871
2872 // AgeInDays is the age of the object in days.
2873 // If you want to set AgeInDays to `0` use AllObjects set to `true`.
2874 AgeInDays <a href="https://pkg.go.dev/builtin#int64">int64</a>
2875
2876 // CreatedBefore is the time the object was created.
2877 //
2878 // This condition is satisfied when an object is created before midnight of
2879 // the specified date in UTC.
2880 CreatedBefore <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Time">Time</a>
2881
2882 // CustomTimeBefore is the CustomTime metadata field of the object. This
2883 // condition is satisfied when an object's CustomTime timestamp is before
2884 // midnight of the specified date in UTC.
2885 //
2886 // This condition can only be satisfied if CustomTime has been set.
2887 CustomTimeBefore <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Time">Time</a>
2888
2889 // DaysSinceCustomTime is the days elapsed since the CustomTime date of the
2890 // object. This condition can only be satisfied if CustomTime has been set.
2891 // Note: Using `0` as the value will be ignored by the library and not sent to the API.
2892 DaysSinceCustomTime <a href="https://pkg.go.dev/builtin#int64">int64</a>
2893
2894 // DaysSinceNoncurrentTime is the days elapsed since the noncurrent timestamp
2895 // of the object. This condition is relevant only for versioned objects.
2896 // Note: Using `0` as the value will be ignored by the library and not sent to the API.
2897 DaysSinceNoncurrentTime <a href="https://pkg.go.dev/builtin#int64">int64</a>
2898
2899 // Liveness specifies the object's liveness. Relevant only for versioned objects
2900 Liveness <a href="#cloud_google_com_go_storage_Liveness">Liveness</a>
2901
2902 // MatchesPrefix is the condition matching an object if any of the
2903 // matches_prefix strings are an exact prefix of the object's name.
2904 MatchesPrefix []<a href="https://pkg.go.dev/builtin#string">string</a>
2905
2906 // MatchesStorageClasses is the condition matching the object's storage
2907 // class.
2908 //
2909 // Values include "STANDARD", "NEARLINE", "COLDLINE" and "ARCHIVE".
2910 MatchesStorageClasses []<a href="https://pkg.go.dev/builtin#string">string</a>
2911
2912 // MatchesSuffix is the condition matching an object if any of the
2913 // matches_suffix strings are an exact suffix of the object's name.
2914 MatchesSuffix []<a href="https://pkg.go.dev/builtin#string">string</a>
2915
2916 // NoncurrentTimeBefore is the noncurrent timestamp of the object. This
2917 // condition is satisfied when an object's noncurrent timestamp is before
2918 // midnight of the specified date in UTC.
2919 //
2920 // This condition is relevant only for versioned objects.
2921 NoncurrentTimeBefore <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Time">Time</a>
2922
2923 // NumNewerVersions is the condition matching objects with a number of newer versions.
2924 //
2925 // If the value is N, this condition is satisfied when there are at least N
2926 // versions (including the live version) newer than this version of the
2927 // object.
2928 // Note: Using `0` as the value will be ignored by the library and not sent to the API.
2929 NumNewerVersions <a href="https://pkg.go.dev/builtin#int64">int64</a>
2930 }
2931 - uid: cloud.google.com/go/storage.LifecycleRule
2932 name: LifecycleRule
2933 id: LifecycleRule
2934 summary: |
2935 LifecycleRule is a lifecycle configuration rule.
2936
2937 When all the configured conditions are met by an object in the bucket, the
2938 configured action will automatically be taken on that object.
2939 parent: cloud.google.com/go/storage
2940 type: type
2941 langs:
2942 - go
2943 syntax:
2944 content: |-
2945 type LifecycleRule struct {
2946 // Action is the action to take when all of the associated conditions are
2947 // met.
2948 Action <a href="#cloud_google_com_go_storage_LifecycleAction">LifecycleAction</a>
2949
2950 // Condition is the set of conditions that must be met for the associated
2951 // action to be taken.
2952 Condition <a href="#cloud_google_com_go_storage_LifecycleCondition">LifecycleCondition</a>
2953 }
2954 - uid: cloud.google.com/go/storage.Liveness
2955 name: Liveness
2956 id: Liveness
2957 summary: |
2958 Liveness specifies whether the object is live or not.
2959 parent: cloud.google.com/go/storage
2960 type: type
2961 langs:
2962 - go
2963 syntax:
2964 content: type Liveness <a href="https://pkg.go.dev/builtin#int">int</a>
2965 - uid: cloud.google.com/go/storage.LiveAndArchived,Live,Archived
2966 name: LiveAndArchived, Live, Archived
2967 id: LiveAndArchived,Live,Archived
2968 parent: cloud.google.com/go/storage.Liveness
2969 type: const
2970 langs:
2971 - go
2972 syntax:
2973 content: |-
2974 const (
2975 // LiveAndArchived includes both live and archived objects.
2976 LiveAndArchived <a href="#cloud_google_com_go_storage_Liveness">Liveness</a> = <a href="https://pkg.go.dev/builtin#iota">iota</a>
2977 // Live specifies that the object is still live.
2978 Live
2979 // Archived specifies that the object is archived.
2980 Archived
2981 )
2982 - uid: cloud.google.com/go/storage.Notification
2983 name: Notification
2984 id: Notification
2985 summary: |
2986 A Notification describes how to send Cloud PubSub messages when certain
2987 events occur in a bucket.
2988 parent: cloud.google.com/go/storage
2989 type: type
2990 langs:
2991 - go
2992 syntax:
2993 content: |-
2994 type Notification struct {
2995 //The ID of the notification.
2996 ID <a href="https://pkg.go.dev/builtin#string">string</a>
2997
2998 // The ID of the topic to which this subscription publishes.
2999 TopicID <a href="https://pkg.go.dev/builtin#string">string</a>
3000
3001 // The ID of the project to which the topic belongs.
3002 TopicProjectID <a href="https://pkg.go.dev/builtin#string">string</a>
3003
3004 // Only send notifications about listed event types. If empty, send notifications
3005 // for all event types.
3006 // See https://cloud.google.com/storage/docs/pubsub-notifications#events.
3007 EventTypes []<a href="https://pkg.go.dev/builtin#string">string</a>
3008
3009 // If present, only apply this notification configuration to object names that
3010 // begin with this prefix.
3011 ObjectNamePrefix <a href="https://pkg.go.dev/builtin#string">string</a>
3012
3013 // An optional list of additional attributes to attach to each Cloud PubSub
3014 // message published for this notification subscription.
3015 CustomAttributes map[<a href="https://pkg.go.dev/builtin#string">string</a>]<a href="https://pkg.go.dev/builtin#string">string</a>
3016
3017 // The contents of the message payload.
3018 // See https://cloud.google.com/storage/docs/pubsub-notifications#payload.
3019 PayloadFormat <a href="https://pkg.go.dev/builtin#string">string</a>
3020 }
3021 - uid: cloud.google.com/go/storage.ObjectAttrs
3022 name: ObjectAttrs
3023 id: ObjectAttrs
3024 summary: |
3025 ObjectAttrs represents the metadata for a Google Cloud Storage (GCS) object.
3026 parent: cloud.google.com/go/storage
3027 type: type
3028 langs:
3029 - go
3030 syntax:
3031 content: |-
3032 type ObjectAttrs struct {
3033 // Bucket is the name of the bucket containing this GCS object.
3034 // This field is read-only.
3035 Bucket <a href="https://pkg.go.dev/builtin#string">string</a>
3036
3037 // Name is the name of the object within the bucket.
3038 // This field is read-only.
3039 Name <a href="https://pkg.go.dev/builtin#string">string</a>
3040
3041 // ContentType is the MIME type of the object's content.
3042 ContentType <a href="https://pkg.go.dev/builtin#string">string</a>
3043
3044 // ContentLanguage is the content language of the object's content.
3045 ContentLanguage <a href="https://pkg.go.dev/builtin#string">string</a>
3046
3047 // CacheControl is the Cache-Control header to be sent in the response
3048 // headers when serving the object data.
3049 CacheControl <a href="https://pkg.go.dev/builtin#string">string</a>
3050
3051 // EventBasedHold specifies whether an object is under event-based hold. New
3052 // objects created in a bucket whose DefaultEventBasedHold is set will
3053 // default to that value.
3054 EventBasedHold <a href="https://pkg.go.dev/builtin#bool">bool</a>
3055
3056 // TemporaryHold specifies whether an object is under temporary hold. While
3057 // this flag is set to true, the object is protected against deletion and
3058 // overwrites.
3059 TemporaryHold <a href="https://pkg.go.dev/builtin#bool">bool</a>
3060
3061 // RetentionExpirationTime is a server-determined value that specifies the
3062 // earliest time that the object's retention period expires.
3063 // This is a read-only field.
3064 RetentionExpirationTime <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Time">Time</a>
3065
3066 // ACL is the list of access control rules for the object.
3067 ACL []<a href="#cloud_google_com_go_storage_ACLRule">ACLRule</a>
3068
3069 // If not empty, applies a predefined set of access controls. It should be set
3070 // only when writing, copying or composing an object. When copying or composing,
3071 // it acts as the destinationPredefinedAcl parameter.
3072 // PredefinedACL is always empty for ObjectAttrs returned from the service.
3073 // See https://cloud.google.com/storage/docs/json_api/v1/objects/insert
3074 // for valid values.
3075 PredefinedACL <a href="https://pkg.go.dev/builtin#string">string</a>
3076
3077 // Owner is the owner of the object. This field is read-only.
3078 //
3079 // If non-zero, it is in the form of "user-<userId>".
3080 Owner <a href="https://pkg.go.dev/builtin#string">string</a>
3081
3082 // Size is the length of the object's content. This field is read-only.
3083 Size <a href="https://pkg.go.dev/builtin#int64">int64</a>
3084
3085 // ContentEncoding is the encoding of the object's content.
3086 ContentEncoding <a href="https://pkg.go.dev/builtin#string">string</a>
3087
3088 // ContentDisposition is the optional Content-Disposition header of the object
3089 // sent in the response headers.
3090 ContentDisposition <a href="https://pkg.go.dev/builtin#string">string</a>
3091
3092 // MD5 is the MD5 hash of the object's content. This field is read-only,
3093 // except when used from a Writer. If set on a Writer, the uploaded
3094 // data is rejected if its MD5 hash does not match this field.
3095 MD5 []<a href="https://pkg.go.dev/builtin#byte">byte</a>
3096
3097 // CRC32C is the CRC32 checksum of the object's content using the Castagnoli93
3098 // polynomial. This field is read-only, except when used from a Writer or
3099 // Composer. In those cases, if the SendCRC32C field in the Writer or Composer
3100 // is set to is true, the uploaded data is rejected if its CRC32C hash does
3101 // not match this field.
3102 //
3103 // Note: For a Writer, SendCRC32C must be set to true BEFORE the first call to
3104 // Writer.Write() in order to send the checksum.
3105 CRC32C <a href="https://pkg.go.dev/builtin#uint32">uint32</a>
3106
3107 // MediaLink is an URL to the object's content. This field is read-only.
3108 MediaLink <a href="https://pkg.go.dev/builtin#string">string</a>
3109
3110 // Metadata represents user-provided metadata, in key/value pairs.
3111 // It can be nil if no metadata is provided.
3112 //
3113 // For object downloads using Reader, metadata keys are sent as headers.
3114 // Therefore, avoid setting metadata keys using characters that are not valid
3115 // for headers. See https://www.rfc-editor.org/rfc/rfc7230#section-3.2.6.
3116 Metadata map[<a href="https://pkg.go.dev/builtin#string">string</a>]<a href="https://pkg.go.dev/builtin#string">string</a>
3117
3118 // Generation is the generation number of the object's content.
3119 // This field is read-only.
3120 Generation <a href="https://pkg.go.dev/builtin#int64">int64</a>
3121
3122 // Metageneration is the version of the metadata for this
3123 // object at this generation. This field is used for preconditions
3124 // and for detecting changes in metadata. A metageneration number
3125 // is only meaningful in the context of a particular generation
3126 // of a particular object. This field is read-only.
3127 Metageneration <a href="https://pkg.go.dev/builtin#int64">int64</a>
3128
3129 // StorageClass is the storage class of the object. This defines
3130 // how objects are stored and determines the SLA and the cost of storage.
3131 // Typical values are "STANDARD", "NEARLINE", "COLDLINE" and "ARCHIVE".
3132 // Defaults to "STANDARD".
3133 // See https://cloud.google.com/storage/docs/storage-classes for all
3134 // valid values.
3135 StorageClass <a href="https://pkg.go.dev/builtin#string">string</a>
3136
3137 // Created is the time the object was created. This field is read-only.
3138 Created <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Time">Time</a>
3139
3140 // Deleted is the time the object was deleted.
3141 // If not deleted, it is the zero value. This field is read-only.
3142 Deleted <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Time">Time</a>
3143
3144 // Updated is the creation or modification time of the object.
3145 // For buckets with versioning enabled, changing an object's
3146 // metadata does not change this property. This field is read-only.
3147 Updated <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Time">Time</a>
3148
3149 // CustomerKeySHA256 is the base64-encoded SHA-256 hash of the
3150 // customer-supplied encryption key for the object. It is empty if there is
3151 // no customer-supplied encryption key.
3152 // See // https://cloud.google.com/storage/docs/encryption for more about
3153 // encryption in Google Cloud Storage.
3154 CustomerKeySHA256 <a href="https://pkg.go.dev/builtin#string">string</a>
3155
3156 // Cloud KMS key name, in the form
3157 // projects/P/locations/L/keyRings/R/cryptoKeys/K, used to encrypt this object,
3158 // if the object is encrypted by such a key.
3159 //
3160 // Providing both a KMSKeyName and a customer-supplied encryption key (via
3161 // ObjectHandle.Key) will result in an error when writing an object.
3162 KMSKeyName <a href="https://pkg.go.dev/builtin#string">string</a>
3163
3164 // Prefix is set only for ObjectAttrs which represent synthetic "directory
3165 // entries" when iterating over buckets using Query.Delimiter. See
3166 // ObjectIterator.Next. When set, no other fields in ObjectAttrs will be
3167 // populated.
3168 Prefix <a href="https://pkg.go.dev/builtin#string">string</a>
3169
3170 // Etag is the HTTP/1.1 Entity tag for the object.
3171 // This field is read-only.
3172 Etag <a href="https://pkg.go.dev/builtin#string">string</a>
3173
3174 // A user-specified timestamp which can be applied to an object. This is
3175 // typically set in order to use the CustomTimeBefore and DaysSinceCustomTime
3176 // LifecycleConditions to manage object lifecycles.
3177 //
3178 // CustomTime cannot be removed once set on an object. It can be updated to a
3179 // later value but not to an earlier one. For more information see
3180 // https://cloud.google.com/storage/docs/metadata#custom-time .
3181 CustomTime <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Time">Time</a>
3182
3183 // ComponentCount is the number of objects contained within a composite object.
3184 // For non-composite objects, the value will be zero.
3185 // This field is read-only.
3186 ComponentCount <a href="https://pkg.go.dev/builtin#int64">int64</a>
3187 }
3188 - uid: cloud.google.com/go/storage.ObjectAttrsToUpdate
3189 name: ObjectAttrsToUpdate
3190 id: ObjectAttrsToUpdate
3191 summary: |
3192 ObjectAttrsToUpdate is used to update the attributes of an object.
3193 Only fields set to non-nil values will be updated.
3194 For all fields except CustomTime, set the field to its zero value to delete
3195 it. CustomTime cannot be deleted or changed to an earlier time once set.
3196
3197 For example, to change ContentType and delete ContentEncoding and
3198 Metadata, use
3199
3200 ObjectAttrsToUpdate{
3201 ContentType: "text/html",
3202 ContentEncoding: "",
3203 Metadata: map[string]string{},
3204 }
3205 parent: cloud.google.com/go/storage
3206 type: type
3207 langs:
3208 - go
3209 syntax:
3210 content: |-
3211 type ObjectAttrsToUpdate struct {
3212 EventBasedHold <a href="https://pkg.go.dev/cloud.google.com/go/internal/optional">optional</a>.<a href="https://pkg.go.dev/cloud.google.com/go/internal/optional#Bool">Bool</a>
3213 TemporaryHold <a href="https://pkg.go.dev/cloud.google.com/go/internal/optional">optional</a>.<a href="https://pkg.go.dev/cloud.google.com/go/internal/optional#Bool">Bool</a>
3214 ContentType <a href="https://pkg.go.dev/cloud.google.com/go/internal/optional">optional</a>.<a href="https://pkg.go.dev/cloud.google.com/go/internal/optional#String">String</a>
3215 ContentLanguage <a href="https://pkg.go.dev/cloud.google.com/go/internal/optional">optional</a>.<a href="https://pkg.go.dev/cloud.google.com/go/internal/optional#String">String</a>
3216 ContentEncoding <a href="https://pkg.go.dev/cloud.google.com/go/internal/optional">optional</a>.<a href="https://pkg.go.dev/cloud.google.com/go/internal/optional#String">String</a>
3217 ContentDisposition <a href="https://pkg.go.dev/cloud.google.com/go/internal/optional">optional</a>.<a href="https://pkg.go.dev/cloud.google.com/go/internal/optional#String">String</a>
3218 CacheControl <a href="https://pkg.go.dev/cloud.google.com/go/internal/optional">optional</a>.<a href="https://pkg.go.dev/cloud.google.com/go/internal/optional#String">String</a>
3219 CustomTime <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Time">Time</a> // Cannot be deleted or backdated from its current value.
3220 Metadata map[<a href="https://pkg.go.dev/builtin#string">string</a>]<a href="https://pkg.go.dev/builtin#string">string</a> // Set to map[string]string{} to delete.
3221 ACL []<a href="#cloud_google_com_go_storage_ACLRule">ACLRule</a>
3222
3223 // If not empty, applies a predefined set of access controls. ACL must be nil.
3224 // See https://cloud.google.com/storage/docs/json_api/v1/objects/patch.
3225 PredefinedACL <a href="https://pkg.go.dev/builtin#string">string</a>
3226 }
3227 - uid: cloud.google.com/go/storage.ObjectHandle
3228 name: ObjectHandle
3229 id: ObjectHandle
3230 summary: |
3231 ObjectHandle provides operations on an object in a Google Cloud Storage bucket.
3232 Use BucketHandle.Object to get a handle.
3233 parent: cloud.google.com/go/storage
3234 type: type
3235 langs:
3236 - go
3237 syntax:
3238 content: |-
3239 type ObjectHandle struct {
3240 // contains filtered or unexported fields
3241 }
3242 codeexamples:
3243 - content: |
3244 package main
3245
3246 import (
3247 "context"
3248 "fmt"
3249
3250 "cloud.google.com/go/storage"
3251 )
3252
3253 func main() {
3254 ctx := context.Background()
3255 client, err := storage.NewClient(ctx)
3256 if err != nil {
3257 // TODO: handle error.
3258 }
3259
3260 attrs, err := client.Bucket("my-bucket").Object("my-object").Attrs(ctx)
3261 if err == storage.ErrObjectNotExist {
3262 fmt.Println("The object does not exist")
3263 return
3264 }
3265 if err != nil {
3266 // TODO: handle error.
3267 }
3268 fmt.Printf("The object exists and has attributes: %#v\n", attrs)
3269 }
3270 name: exists
3271 - uid: cloud.google.com/go/storage.ObjectHandle.ACL
3272 name: |
3273 func (*ObjectHandle) ACL
3274 id: ACL
3275 summary: |
3276 ACL provides access to the object's access control list.
3277 This controls who can read and write this object.
3278 This call does not perform any network operations.
3279 parent: cloud.google.com/go/storage.ObjectHandle
3280 type: method
3281 langs:
3282 - go
3283 syntax:
3284 content: func (o *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>) ACL() *<a href="#cloud_google_com_go_storage_ACLHandle">ACLHandle</a>
3285 - uid: cloud.google.com/go/storage.ObjectHandle.Attrs
3286 name: |
3287 func (*ObjectHandle) Attrs
3288 id: Attrs
3289 summary: |
3290 Attrs returns meta information about the object.
3291 ErrObjectNotExist will be returned if the object is not found.
3292 parent: cloud.google.com/go/storage.ObjectHandle
3293 type: method
3294 langs:
3295 - go
3296 syntax:
3297 content: func (o *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>) Attrs(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) (attrs *<a href="#cloud_google_com_go_storage_ObjectAttrs">ObjectAttrs</a>, err <a href="https://pkg.go.dev/builtin#error">error</a>)
3298 codeexamples:
3299 - content: |
3300 package main
3301
3302 import (
3303 "context"
3304 "fmt"
3305
3306 "cloud.google.com/go/storage"
3307 )
3308
3309 func main() {
3310 ctx := context.Background()
3311 client, err := storage.NewClient(ctx)
3312 if err != nil {
3313 // TODO: handle error.
3314 }
3315 objAttrs, err := client.Bucket("my-bucket").Object("my-object").Attrs(ctx)
3316 if err != nil {
3317 // TODO: handle error.
3318 }
3319 fmt.Println(objAttrs)
3320 }
3321 - content: |
3322 package main
3323
3324 import (
3325 "context"
3326 "fmt"
3327 "time"
3328
3329 "cloud.google.com/go/storage"
3330 )
3331
3332 func main() {
3333 ctx := context.Background()
3334 client, err := storage.NewClient(ctx)
3335 if err != nil {
3336 // TODO: handle error.
3337 }
3338 obj := client.Bucket("my-bucket").Object("my-object")
3339 // Read the object.
3340 objAttrs1, err := obj.Attrs(ctx)
3341 if err != nil {
3342 // TODO: handle error.
3343 }
3344 // Do something else for a while.
3345 time.Sleep(5 * time.Minute)
3346 // Now read the same contents, even if the object has been written since the last read.
3347 objAttrs2, err := obj.Generation(objAttrs1.Generation).Attrs(ctx)
3348 if err != nil {
3349 // TODO: handle error.
3350 }
3351 fmt.Println(objAttrs1, objAttrs2)
3352 }
3353 name: withConditions
3354 - uid: cloud.google.com/go/storage.ObjectHandle.BucketName
3355 name: |
3356 func (*ObjectHandle) BucketName
3357 id: BucketName
3358 summary: |
3359 BucketName returns the name of the bucket.
3360 parent: cloud.google.com/go/storage.ObjectHandle
3361 type: method
3362 langs:
3363 - go
3364 syntax:
3365 content: func (o *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>) BucketName() <a href="https://pkg.go.dev/builtin#string">string</a>
3366 - uid: cloud.google.com/go/storage.ObjectHandle.ComposerFrom
3367 name: |
3368 func (*ObjectHandle) ComposerFrom
3369 id: ComposerFrom
3370 summary: |
3371 ComposerFrom creates a Composer that can compose srcs into dst.
3372 You can immediately call Run on the returned Composer, or you can
3373 configure it first.
3374
3375 The encryption key for the destination object will be used to decrypt all
3376 source objects and encrypt the destination object. It is an error
3377 to specify an encryption key for any of the source objects.
3378 parent: cloud.google.com/go/storage.ObjectHandle
3379 type: method
3380 langs:
3381 - go
3382 syntax:
3383 content: func (dst *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>) ComposerFrom(srcs ...*<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>) *<a href="#cloud_google_com_go_storage_Composer">Composer</a>
3384 - uid: cloud.google.com/go/storage.ObjectHandle.CopierFrom
3385 name: |
3386 func (*ObjectHandle) CopierFrom
3387 id: CopierFrom
3388 summary: |
3389 CopierFrom creates a Copier that can copy src to dst.
3390 You can immediately call Run on the returned Copier, or
3391 you can configure it first.
3392
3393 For Requester Pays buckets, the user project of dst is billed, unless it is empty,
3394 in which case the user project of src is billed.
3395 parent: cloud.google.com/go/storage.ObjectHandle
3396 type: method
3397 langs:
3398 - go
3399 syntax:
3400 content: func (dst *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>) CopierFrom(src *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>) *<a href="#cloud_google_com_go_storage_Copier">Copier</a>
3401 codeexamples:
3402 - content: |
3403 package main
3404
3405 import (
3406 "context"
3407
3408 "cloud.google.com/go/storage"
3409 )
3410
3411 var key1, key2 []byte
3412
3413 func main() {
3414 // To rotate the encryption key on an object, copy it onto itself.
3415 ctx := context.Background()
3416 client, err := storage.NewClient(ctx)
3417 if err != nil {
3418 // TODO: handle error.
3419 }
3420 obj := client.Bucket("bucketname").Object("obj")
3421 // Assume obj is encrypted with key1, and we want to change to key2.
3422 _, err = obj.Key(key2).CopierFrom(obj.Key(key1)).Run(ctx)
3423 if err != nil {
3424 // TODO: handle error.
3425 }
3426 }
3427 name: rotateEncryptionKeys
3428 - uid: cloud.google.com/go/storage.ObjectHandle.Delete
3429 name: |
3430 func (*ObjectHandle) Delete
3431 id: Delete
3432 summary: |
3433 Delete deletes the single specified object.
3434 parent: cloud.google.com/go/storage.ObjectHandle
3435 type: method
3436 langs:
3437 - go
3438 syntax:
3439 content: func (o *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>) Delete(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) <a href="https://pkg.go.dev/builtin#error">error</a>
3440 codeexamples:
3441 - content: |
3442 package main
3443
3444 import (
3445 "context"
3446 "fmt"
3447
3448 "cloud.google.com/go/storage"
3449 "google.golang.org/api/iterator"
3450 )
3451
3452 func main() {
3453 ctx := context.Background()
3454 client, err := storage.NewClient(ctx)
3455 if err != nil {
3456 // TODO: handle error.
3457 }
3458 // To delete multiple objects in a bucket, list them with an
3459 // ObjectIterator, then Delete them.
3460
3461 // If you are using this package on the App Engine Flex runtime,
3462 // you can init a bucket client with your app's default bucket name.
3463 // See http://godoc.org/google.golang.org/appengine/file#DefaultBucketName.
3464 bucket := client.Bucket("my-bucket")
3465 it := bucket.Objects(ctx, nil)
3466 for {
3467 objAttrs, err := it.Next()
3468 if err != nil && err != iterator.Done {
3469 // TODO: Handle error.
3470 }
3471 if err == iterator.Done {
3472 break
3473 }
3474 if err := bucket.Object(objAttrs.Name).Delete(ctx); err != nil {
3475 // TODO: Handle error.
3476 }
3477 }
3478 fmt.Println("deleted all object items in the bucket specified.")
3479 }
3480 - uid: cloud.google.com/go/storage.ObjectHandle.Generation
3481 name: |
3482 func (*ObjectHandle) Generation
3483 id: Generation
3484 summary: |
3485 Generation returns a new ObjectHandle that operates on a specific generation
3486 of the object.
3487 By default, the handle operates on the latest generation. Not
3488 all operations work when given a specific generation; check the API
3489 endpoints at https://cloud.google.com/storage/docs/json_api/ for details.
3490 parent: cloud.google.com/go/storage.ObjectHandle
3491 type: method
3492 langs:
3493 - go
3494 syntax:
3495 content: func (o *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>) Generation(gen <a href="https://pkg.go.dev/builtin#int64">int64</a>) *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>
3496 codeexamples:
3497 - content: |
3498 package main
3499
3500 import (
3501 "context"
3502 "io"
3503 "os"
3504
3505 "cloud.google.com/go/storage"
3506 )
3507
3508 var gen int64
3509
3510 func main() {
3511 // Read an object's contents from generation gen, regardless of the
3512 // current generation of the object.
3513 ctx := context.Background()
3514 client, err := storage.NewClient(ctx)
3515 if err != nil {
3516 // TODO: handle error.
3517 }
3518 obj := client.Bucket("my-bucket").Object("my-object")
3519 rc, err := obj.Generation(gen).NewReader(ctx)
3520 if err != nil {
3521 // TODO: handle error.
3522 }
3523 defer rc.Close()
3524 if _, err := io.Copy(os.Stdout, rc); err != nil {
3525 // TODO: handle error.
3526 }
3527 }
3528 - uid: cloud.google.com/go/storage.ObjectHandle.If
3529 name: |
3530 func (*ObjectHandle) If
3531 id: If
3532 summary: |
3533 If returns a new ObjectHandle that applies a set of preconditions.
3534 Preconditions already set on the ObjectHandle are ignored. The supplied
3535 Conditions must have at least one field set to a non-default value;
3536 otherwise an error will be returned from any operation on the ObjectHandle.
3537 Operations on the new handle will return an error if the preconditions are not
3538 satisfied. See https://cloud.google.com/storage/docs/generations-preconditions
3539 for more details.
3540 parent: cloud.google.com/go/storage.ObjectHandle
3541 type: method
3542 langs:
3543 - go
3544 syntax:
3545 content: func (o *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>) If(conds <a href="#cloud_google_com_go_storage_Conditions">Conditions</a>) *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>
3546 codeexamples:
3547 - content: |
3548 package main
3549
3550 import (
3551 "context"
3552 "io"
3553 "net/http"
3554 "os"
3555
3556 "cloud.google.com/go/storage"
3557 "google.golang.org/api/googleapi"
3558 )
3559
3560 var gen int64
3561
3562 func main() {
3563 // Read from an object only if the current generation is gen.
3564 ctx := context.Background()
3565 client, err := storage.NewClient(ctx)
3566 if err != nil {
3567 // TODO: handle error.
3568 }
3569 obj := client.Bucket("my-bucket").Object("my-object")
3570 rc, err := obj.If(storage.Conditions{GenerationMatch: gen}).NewReader(ctx)
3571 if err != nil {
3572 // TODO: handle error.
3573 }
3574
3575 if _, err := io.Copy(os.Stdout, rc); err != nil {
3576 // TODO: handle error.
3577 }
3578 if err := rc.Close(); err != nil {
3579 switch ee := err.(type) {
3580 case *googleapi.Error:
3581 if ee.Code == http.StatusPreconditionFailed {
3582 // The condition presented in the If failed.
3583 // TODO: handle error.
3584 }
3585
3586 // TODO: handle other status codes here.
3587
3588 default:
3589 // TODO: handle error.
3590 }
3591 }
3592 }
3593 - uid: cloud.google.com/go/storage.ObjectHandle.Key
3594 name: |
3595 func (*ObjectHandle) Key
3596 id: Key
3597 summary: |
3598 Key returns a new ObjectHandle that uses the supplied encryption
3599 key to encrypt and decrypt the object's contents.
3600
3601 Encryption key must be a 32-byte AES-256 key.
3602 See https://cloud.google.com/storage/docs/encryption for details.
3603 parent: cloud.google.com/go/storage.ObjectHandle
3604 type: method
3605 langs:
3606 - go
3607 syntax:
3608 content: func (o *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>) Key(encryptionKey []<a href="https://pkg.go.dev/builtin#byte">byte</a>) *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>
3609 codeexamples:
3610 - content: |
3611 package main
3612
3613 import (
3614 "context"
3615
3616 "cloud.google.com/go/storage"
3617 )
3618
3619 var secretKey []byte
3620
3621 func main() {
3622 ctx := context.Background()
3623 client, err := storage.NewClient(ctx)
3624 if err != nil {
3625 // TODO: handle error.
3626 }
3627 obj := client.Bucket("my-bucket").Object("my-object")
3628 // Encrypt the object's contents.
3629 w := obj.Key(secretKey).NewWriter(ctx)
3630 if _, err := w.Write([]byte("top secret")); err != nil {
3631 // TODO: handle error.
3632 }
3633 if err := w.Close(); err != nil {
3634 // TODO: handle error.
3635 }
3636 }
3637 - uid: cloud.google.com/go/storage.ObjectHandle.NewRangeReader
3638 name: |
3639 func (*ObjectHandle) NewRangeReader
3640 id: NewRangeReader
3641 summary: |
3642 NewRangeReader reads part of an object, reading at most length bytes
3643 starting at the given offset. If length is negative, the object is read
3644 until the end. If offset is negative, the object is read abs(offset) bytes
3645 from the end, and length must also be negative to indicate all remaining
3646 bytes will be read.
3647
3648 If the object's metadata property "Content-Encoding" is set to "gzip" or satisfies
3649 decompressive transcoding per https://cloud.google.com/storage/docs/transcoding
3650 that file will be served back whole, regardless of the requested range as
3651 Google Cloud Storage dictates.
3652 parent: cloud.google.com/go/storage.ObjectHandle
3653 type: method
3654 langs:
3655 - go
3656 syntax:
3657 content: func (o *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>) NewRangeReader(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, offset, length <a href="https://pkg.go.dev/builtin#int64">int64</a>) (r *<a href="#cloud_google_com_go_storage_Reader">Reader</a>, err <a href="https://pkg.go.dev/builtin#error">error</a>)
3658 codeexamples:
3659 - content: |
3660 package main
3661
3662 import (
3663 "context"
3664 "fmt"
3665 "io/ioutil"
3666
3667 "cloud.google.com/go/storage"
3668 )
3669
3670 func main() {
3671 ctx := context.Background()
3672 client, err := storage.NewClient(ctx)
3673 if err != nil {
3674 // TODO: handle error.
3675 }
3676 // Read only the first 64K.
3677 rc, err := client.Bucket("bucketname").Object("filename1").NewRangeReader(ctx, 0, 64*1024)
3678 if err != nil {
3679 // TODO: handle error.
3680 }
3681 defer rc.Close()
3682
3683 slurp, err := ioutil.ReadAll(rc)
3684 if err != nil {
3685 // TODO: handle error.
3686 }
3687 fmt.Printf("first 64K of file contents:\n%s\n", slurp)
3688 }
3689 - content: |
3690 package main
3691
3692 import (
3693 "context"
3694 "fmt"
3695 "io/ioutil"
3696
3697 "cloud.google.com/go/storage"
3698 )
3699
3700 func main() {
3701 ctx := context.Background()
3702 client, err := storage.NewClient(ctx)
3703 if err != nil {
3704 // TODO: handle error.
3705 }
3706 // Read only the last 10 bytes until the end of the file.
3707 rc, err := client.Bucket("bucketname").Object("filename1").NewRangeReader(ctx, -10, -1)
3708 if err != nil {
3709 // TODO: handle error.
3710 }
3711 defer rc.Close()
3712
3713 slurp, err := ioutil.ReadAll(rc)
3714 if err != nil {
3715 // TODO: handle error.
3716 }
3717 fmt.Printf("Last 10 bytes from the end of the file:\n%s\n", slurp)
3718 }
3719 name: lastNBytes
3720 - content: |
3721 package main
3722
3723 import (
3724 "context"
3725 "fmt"
3726 "io/ioutil"
3727
3728 "cloud.google.com/go/storage"
3729 )
3730
3731 func main() {
3732 ctx := context.Background()
3733 client, err := storage.NewClient(ctx)
3734 if err != nil {
3735 // TODO: handle error.
3736 }
3737 // Read from the 101st byte until the end of the file.
3738 rc, err := client.Bucket("bucketname").Object("filename1").NewRangeReader(ctx, 100, -1)
3739 if err != nil {
3740 // TODO: handle error.
3741 }
3742 defer rc.Close()
3743
3744 slurp, err := ioutil.ReadAll(rc)
3745 if err != nil {
3746 // TODO: handle error.
3747 }
3748 fmt.Printf("From 101st byte until the end:\n%s\n", slurp)
3749 }
3750 name: untilEnd
3751 - uid: cloud.google.com/go/storage.ObjectHandle.NewReader
3752 name: |
3753 func (*ObjectHandle) NewReader
3754 id: NewReader
3755 summary: |
3756 NewReader creates a new Reader to read the contents of the
3757 object.
3758 ErrObjectNotExist will be returned if the object is not found.
3759
3760 The caller must call Close on the returned Reader when done reading.
3761 parent: cloud.google.com/go/storage.ObjectHandle
3762 type: method
3763 langs:
3764 - go
3765 syntax:
3766 content: func (o *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>) NewReader(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) (*<a href="#cloud_google_com_go_storage_Reader">Reader</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)
3767 codeexamples:
3768 - content: |
3769 package main
3770
3771 import (
3772 "context"
3773 "fmt"
3774 "io/ioutil"
3775
3776 "cloud.google.com/go/storage"
3777 )
3778
3779 func main() {
3780 ctx := context.Background()
3781 client, err := storage.NewClient(ctx)
3782 if err != nil {
3783 // TODO: handle error.
3784 }
3785 rc, err := client.Bucket("my-bucket").Object("my-object").NewReader(ctx)
3786 if err != nil {
3787 // TODO: handle error.
3788 }
3789 slurp, err := ioutil.ReadAll(rc)
3790 rc.Close()
3791 if err != nil {
3792 // TODO: handle error.
3793 }
3794 fmt.Println("file contents:", slurp)
3795 }
3796 - uid: cloud.google.com/go/storage.ObjectHandle.NewWriter
3797 name: |
3798 func (*ObjectHandle) NewWriter
3799 id: NewWriter
3800 summary: |
3801 NewWriter returns a storage Writer that writes to the GCS object
3802 associated with this ObjectHandle.
3803
3804 A new object will be created unless an object with this name already exists.
3805 Otherwise any previous object with the same name will be replaced.
3806 The object will not be available (and any previous object will remain)
3807 until Close has been called.
3808
3809 Attributes can be set on the object by modifying the returned Writer's
3810 ObjectAttrs field before the first call to Write. If no ContentType
3811 attribute is specified, the content type will be automatically sniffed
3812 using net/http.DetectContentType.
3813
3814 Note that each Writer allocates an internal buffer of size Writer.ChunkSize.
3815 See the ChunkSize docs for more information.
3816
3817 It is the caller's responsibility to call Close when writing is done. To
3818 stop writing without saving the data, cancel the context.
3819 parent: cloud.google.com/go/storage.ObjectHandle
3820 type: method
3821 langs:
3822 - go
3823 syntax:
3824 content: func (o *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>) NewWriter(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) *<a href="#cloud_google_com_go_storage_Writer">Writer</a>
3825 codeexamples:
3826 - content: |
3827 package main
3828
3829 import (
3830 "context"
3831
3832 "cloud.google.com/go/storage"
3833 )
3834
3835 func main() {
3836 ctx := context.Background()
3837 client, err := storage.NewClient(ctx)
3838 if err != nil {
3839 // TODO: handle error.
3840 }
3841 wc := client.Bucket("bucketname").Object("filename1").NewWriter(ctx)
3842 _ = wc // TODO: Use the Writer.
3843 }
3844 - uid: cloud.google.com/go/storage.ObjectHandle.ObjectName
3845 name: |
3846 func (*ObjectHandle) ObjectName
3847 id: ObjectName
3848 summary: |
3849 ObjectName returns the name of the object.
3850 parent: cloud.google.com/go/storage.ObjectHandle
3851 type: method
3852 langs:
3853 - go
3854 syntax:
3855 content: func (o *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>) ObjectName() <a href="https://pkg.go.dev/builtin#string">string</a>
3856 - uid: cloud.google.com/go/storage.ObjectHandle.ReadCompressed
3857 name: |
3858 func (*ObjectHandle) ReadCompressed
3859 id: ReadCompressed
3860 summary: |
3861 ReadCompressed when true causes the read to happen without decompressing.
3862 parent: cloud.google.com/go/storage.ObjectHandle
3863 type: method
3864 langs:
3865 - go
3866 syntax:
3867 content: func (o *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>) ReadCompressed(compressed <a href="https://pkg.go.dev/builtin#bool">bool</a>) *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>
3868 - uid: cloud.google.com/go/storage.ObjectHandle.Retryer
3869 name: |
3870 func (*ObjectHandle) Retryer
3871 id: Retryer
3872 summary: |
3873 Retryer returns an object handle that is configured with custom retry
3874 behavior as specified by the options that are passed to it. All operations
3875 on the new handle will use the customized retry configuration.
3876 These retry options will merge with the bucket's retryer (if set) for the
3877 returned handle. Options passed into this method will take precedence over
3878 retry options on the bucket and client. Note that you must explicitly pass in
3879 each option you want to override.
3880 parent: cloud.google.com/go/storage.ObjectHandle
3881 type: method
3882 langs:
3883 - go
3884 syntax:
3885 content: func (o *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>) Retryer(opts ...<a href="#cloud_google_com_go_storage_RetryOption">RetryOption</a>) *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>
3886 - uid: cloud.google.com/go/storage.ObjectHandle.Update
3887 name: |
3888 func (*ObjectHandle) Update
3889 id: Update
3890 summary: |
3891 Update updates an object with the provided attributes. See
3892 ObjectAttrsToUpdate docs for details on treatment of zero values.
3893 ErrObjectNotExist will be returned if the object is not found.
3894 parent: cloud.google.com/go/storage.ObjectHandle
3895 type: method
3896 langs:
3897 - go
3898 syntax:
3899 content: func (o *<a href="#cloud_google_com_go_storage_ObjectHandle">ObjectHandle</a>) Update(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, uattrs <a href="#cloud_google_com_go_storage_ObjectAttrsToUpdate">ObjectAttrsToUpdate</a>) (oa *<a href="#cloud_google_com_go_storage_ObjectAttrs">ObjectAttrs</a>, err <a href="https://pkg.go.dev/builtin#error">error</a>)
3900 codeexamples:
3901 - content: |
3902 package main
3903
3904 import (
3905 "context"
3906 "fmt"
3907
3908 "cloud.google.com/go/storage"
3909 )
3910
3911 func main() {
3912 ctx := context.Background()
3913 client, err := storage.NewClient(ctx)
3914 if err != nil {
3915 // TODO: handle error.
3916 }
3917 // Change only the content type of the object.
3918 objAttrs, err := client.Bucket("my-bucket").Object("my-object").Update(ctx, storage.ObjectAttrsToUpdate{
3919 ContentType: "text/html",
3920 ContentDisposition: "", // delete ContentDisposition
3921 })
3922 if err != nil {
3923 // TODO: handle error.
3924 }
3925 fmt.Println(objAttrs)
3926 }
3927 - uid: cloud.google.com/go/storage.ObjectIterator
3928 name: ObjectIterator
3929 id: ObjectIterator
3930 summary: |
3931 An ObjectIterator is an iterator over ObjectAttrs.
3932
3933 Note: This iterator is not safe for concurrent operations without explicit synchronization.
3934 parent: cloud.google.com/go/storage
3935 type: type
3936 langs:
3937 - go
3938 syntax:
3939 content: |-
3940 type ObjectIterator struct {
3941 // contains filtered or unexported fields
3942 }
3943 - uid: cloud.google.com/go/storage.ObjectIterator.Next
3944 name: |
3945 func (*ObjectIterator) Next
3946 id: Next
3947 summary: |
3948 Next returns the next result. Its second return value is iterator.Done if
3949 there are no more results. Once Next returns iterator.Done, all subsequent
3950 calls will return iterator.Done.
3951
3952 In addition, if Next returns an error other than iterator.Done, all
3953 subsequent calls will return the same error. To continue iteration, a new
3954 `ObjectIterator` must be created. Since objects are ordered lexicographically
3955 by name, `Query.StartOffset` can be used to create a new iterator which will
3956 start at the desired place. See
3957 https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#hdr-Listing_objects.
3958
3959 If Query.Delimiter is non-empty, some of the ObjectAttrs returned by Next will
3960 have a non-empty Prefix field, and a zero value for all other fields. These
3961 represent prefixes.
3962
3963 Note: This method is not safe for concurrent operations without explicit synchronization.
3964 parent: cloud.google.com/go/storage.ObjectIterator
3965 type: method
3966 langs:
3967 - go
3968 syntax:
3969 content: func (it *<a href="#cloud_google_com_go_storage_ObjectIterator">ObjectIterator</a>) Next() (*<a href="#cloud_google_com_go_storage_ObjectAttrs">ObjectAttrs</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)
3970 codeexamples:
3971 - content: |
3972 package main
3973
3974 import (
3975 "context"
3976 "fmt"
3977
3978 "cloud.google.com/go/storage"
3979 "google.golang.org/api/iterator"
3980 )
3981
3982 func main() {
3983 ctx := context.Background()
3984 client, err := storage.NewClient(ctx)
3985 if err != nil {
3986 // TODO: handle error.
3987 }
3988 it := client.Bucket("my-bucket").Objects(ctx, nil)
3989 for {
3990 objAttrs, err := it.Next()
3991 if err == iterator.Done {
3992 break
3993 }
3994 if err != nil {
3995 // TODO: Handle error.
3996 }
3997 fmt.Println(objAttrs)
3998 }
3999 }
4000 - uid: cloud.google.com/go/storage.ObjectIterator.PageInfo
4001 name: |
4002 func (*ObjectIterator) PageInfo
4003 id: PageInfo
4004 summary: |
4005 PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
4006
4007 Note: This method is not safe for concurrent operations without explicit synchronization.
4008 parent: cloud.google.com/go/storage.ObjectIterator
4009 type: method
4010 langs:
4011 - go
4012 syntax:
4013 content: func (it *<a href="#cloud_google_com_go_storage_ObjectIterator">ObjectIterator</a>) PageInfo() *<a href="https://pkg.go.dev/google.golang.org/api/iterator">iterator</a>.<a href="https://pkg.go.dev/google.golang.org/api/iterator#PageInfo">PageInfo</a>
4014 - uid: cloud.google.com/go/storage.PolicyV4Fields
4015 name: PolicyV4Fields
4016 id: PolicyV4Fields
4017 summary: |
4018 PolicyV4Fields describes the attributes for a PostPolicyV4 request.
4019 parent: cloud.google.com/go/storage
4020 type: type
4021 langs:
4022 - go
4023 syntax:
4024 content: |-
4025 type PolicyV4Fields struct {
4026 // ACL specifies the access control permissions for the object.
4027 // Optional.
4028 ACL <a href="https://pkg.go.dev/builtin#string">string</a>
4029 // CacheControl specifies the caching directives for the object.
4030 // Optional.
4031 CacheControl <a href="https://pkg.go.dev/builtin#string">string</a>
4032 // ContentType specifies the media type of the object.
4033 // Optional.
4034 ContentType <a href="https://pkg.go.dev/builtin#string">string</a>
4035 // ContentDisposition specifies how the file will be served back to requesters.
4036 // Optional.
4037 ContentDisposition <a href="https://pkg.go.dev/builtin#string">string</a>
4038 // ContentEncoding specifies the decompressive transcoding that the object.
4039 // This field is complementary to ContentType in that the file could be
4040 // compressed but ContentType specifies the file's original media type.
4041 // Optional.
4042 ContentEncoding <a href="https://pkg.go.dev/builtin#string">string</a>
4043 // Metadata specifies custom metadata for the object.
4044 // If any key doesn't begin with "x-goog-meta-", an error will be returned.
4045 // Optional.
4046 Metadata map[<a href="https://pkg.go.dev/builtin#string">string</a>]<a href="https://pkg.go.dev/builtin#string">string</a>
4047 // StatusCodeOnSuccess when set, specifies the status code that Cloud Storage
4048 // will serve back on successful upload of the object.
4049 // Optional.
4050 StatusCodeOnSuccess <a href="https://pkg.go.dev/builtin#int">int</a>
4051 // RedirectToURLOnSuccess when set, specifies the URL that Cloud Storage
4052 // will serve back on successful upload of the object.
4053 // Optional.
4054 RedirectToURLOnSuccess <a href="https://pkg.go.dev/builtin#string">string</a>
4055 }
4056 - uid: cloud.google.com/go/storage.PostPolicyV4
4057 name: PostPolicyV4
4058 id: PostPolicyV4
4059 summary: |
4060 PostPolicyV4 describes the URL and respective form fields for a generated PostPolicyV4 request.
4061 parent: cloud.google.com/go/storage
4062 type: type
4063 langs:
4064 - go
4065 syntax:
4066 content: |-
4067 type PostPolicyV4 struct {
4068 // URL is the generated URL that the file upload will be made to.
4069 URL <a href="https://pkg.go.dev/builtin#string">string</a>
4070 // Fields specifies the generated key-values that the file uploader
4071 // must include in their multipart upload form.
4072 Fields map[<a href="https://pkg.go.dev/builtin#string">string</a>]<a href="https://pkg.go.dev/builtin#string">string</a>
4073 }
4074 - uid: cloud.google.com/go/storage.PostPolicyV4.GenerateSignedPostPolicyV4
4075 name: |
4076 func GenerateSignedPostPolicyV4
4077 id: GenerateSignedPostPolicyV4
4078 summary: |
4079 GenerateSignedPostPolicyV4 generates a PostPolicyV4 value from bucket, object and opts.
4080 The generated URL and fields will then allow an unauthenticated client to perform multipart uploads.
4081 If initializing a Storage Client, instead use the Bucket.GenerateSignedPostPolicyV4
4082 method which uses the Client's credentials to handle authentication.
4083 parent: cloud.google.com/go/storage.PostPolicyV4
4084 type: function
4085 langs:
4086 - go
4087 syntax:
4088 content: func GenerateSignedPostPolicyV4(bucket, object <a href="https://pkg.go.dev/builtin#string">string</a>, opts *<a href="#cloud_google_com_go_storage_PostPolicyV4Options">PostPolicyV4Options</a>) (*<a href="#cloud_google_com_go_storage_PostPolicyV4">PostPolicyV4</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)
4089 codeexamples:
4090 - content: |
4091 package main
4092
4093 import (
4094 "bytes"
4095 "io"
4096 "mime/multipart"
4097 "net/http"
4098 "time"
4099
4100 "cloud.google.com/go/storage"
4101 )
4102
4103 func main() {
4104 pv4, err := storage.GenerateSignedPostPolicyV4("my-bucket", "my-object.txt", &storage.PostPolicyV4Options{
4105 GoogleAccessID: "my-access-id",
4106 PrivateKey: []byte("my-private-key"),
4107
4108 // The upload expires in 2hours.
4109 Expires: time.Now().Add(2 * time.Hour),
4110
4111 Fields: &storage.PolicyV4Fields{
4112 StatusCodeOnSuccess: 200,
4113 RedirectToURLOnSuccess: "https://example.org/",
4114 // It MUST only be a text file.
4115 ContentType: "text/plain",
4116 },
4117
4118 // The conditions that the uploaded file will be expected to conform to.
4119 Conditions: []storage.PostPolicyV4Condition{
4120 // Make the file a maximum of 10mB.
4121 storage.ConditionContentLengthRange(0, 10<<20),
4122 },
4123 })
4124 if err != nil {
4125 // TODO: handle error.
4126 }
4127
4128 // Now you can upload your file using the generated post policy
4129 // with a plain HTTP client or even the browser.
4130 formBuf := new(bytes.Buffer)
4131 mw := multipart.NewWriter(formBuf)
4132 for fieldName, value := range pv4.Fields {
4133 if err := mw.WriteField(fieldName, value); err != nil {
4134 // TODO: handle error.
4135 }
4136 }
4137 file := bytes.NewReader(bytes.Repeat([]byte("a"), 100))
4138
4139 mf, err := mw.CreateFormFile("file", "myfile.txt")
4140 if err != nil {
4141 // TODO: handle error.
4142 }
4143 if _, err := io.Copy(mf, file); err != nil {
4144 // TODO: handle error.
4145 }
4146 if err := mw.Close(); err != nil {
4147 // TODO: handle error.
4148 }
4149
4150 // Compose the request.
4151 req, err := http.NewRequest("POST", pv4.URL, formBuf)
4152 if err != nil {
4153 // TODO: handle error.
4154 }
4155 // Ensure the Content-Type is derived from the multipart writer.
4156 req.Header.Set("Content-Type", mw.FormDataContentType())
4157 res, err := http.DefaultClient.Do(req)
4158 if err != nil {
4159 // TODO: handle error.
4160 }
4161 _ = res
4162 }
4163 - uid: cloud.google.com/go/storage.PostPolicyV4Condition
4164 name: PostPolicyV4Condition
4165 id: PostPolicyV4Condition
4166 summary: |
4167 PostPolicyV4Condition describes the constraints that the subsequent
4168 object upload's multipart form fields will be expected to conform to.
4169 parent: cloud.google.com/go/storage
4170 type: type
4171 langs:
4172 - go
4173 syntax:
4174 content: |-
4175 type PostPolicyV4Condition interface {
4176 <a href="https://pkg.go.dev/encoding/json">json</a>.<a href="https://pkg.go.dev/encoding/json#Marshaler">Marshaler</a>
4177 // contains filtered or unexported methods
4178 }
4179 - uid: cloud.google.com/go/storage.PostPolicyV4Condition.ConditionContentLengthRange
4180 name: |
4181 func ConditionContentLengthRange
4182 id: ConditionContentLengthRange
4183 summary: |
4184 ConditionContentLengthRange constraints the limits that the
4185 multipart upload's range header will be expected to be within.
4186 parent: cloud.google.com/go/storage.PostPolicyV4Condition
4187 type: function
4188 langs:
4189 - go
4190 syntax:
4191 content: func ConditionContentLengthRange(start, end <a href="https://pkg.go.dev/builtin#uint64">uint64</a>) <a href="#cloud_google_com_go_storage_PostPolicyV4Condition">PostPolicyV4Condition</a>
4192 - uid: cloud.google.com/go/storage.PostPolicyV4Condition.ConditionStartsWith
4193 name: |
4194 func ConditionStartsWith
4195 id: ConditionStartsWith
4196 summary: |
4197 ConditionStartsWith checks that an attributes starts with value.
4198 An empty value will cause this condition to be ignored.
4199 parent: cloud.google.com/go/storage.PostPolicyV4Condition
4200 type: function
4201 langs:
4202 - go
4203 syntax:
4204 content: func ConditionStartsWith(key, value <a href="https://pkg.go.dev/builtin#string">string</a>) <a href="#cloud_google_com_go_storage_PostPolicyV4Condition">PostPolicyV4Condition</a>
4205 - uid: cloud.google.com/go/storage.PostPolicyV4Options
4206 name: PostPolicyV4Options
4207 id: PostPolicyV4Options
4208 summary: |
4209 PostPolicyV4Options are used to construct a signed post policy.
4210 Please see https://cloud.google.com/storage/docs/xml-api/post-object
4211 for reference about the fields.
4212 parent: cloud.google.com/go/storage
4213 type: type
4214 langs:
4215 - go
4216 syntax:
4217 content: |-
4218 type PostPolicyV4Options struct {
4219 // GoogleAccessID represents the authorizer of the signed post policy generation.
4220 // It is typically the Google service account client email address from
4221 // the Google Developers Console in the form of "[email protected]".
4222 // Required.
4223 GoogleAccessID <a href="https://pkg.go.dev/builtin#string">string</a>
4224
4225 // PrivateKey is the Google service account private key. It is obtainable
4226 // from the Google Developers Console.
4227 // At https://console.developers.google.com/project/<your-project-id>/apiui/credential,
4228 // create a service account client ID or reuse one of your existing service account
4229 // credentials. Click on the "Generate new P12 key" to generate and download
4230 // a new private key. Once you download the P12 file, use the following command
4231 // to convert it into a PEM file.
4232 //
4233 // $ openssl pkcs12 -in key.p12 -passin pass:notasecret -out key.pem -nodes
4234 //
4235 // Provide the contents of the PEM file as a byte slice.
4236 // Exactly one of PrivateKey or SignBytes must be non-nil.
4237 PrivateKey []<a href="https://pkg.go.dev/builtin#byte">byte</a>
4238
4239 // SignBytes is a function for implementing custom signing.
4240 //
4241 // Deprecated: Use SignRawBytes. If both SignBytes and SignRawBytes are defined,
4242 // SignBytes will be ignored.
4243 // This SignBytes function expects the bytes it receives to be hashed, while
4244 // SignRawBytes accepts the raw bytes without hashing, allowing more flexibility.
4245 // Add the following to the top of your signing function to hash the bytes
4246 // to use SignRawBytes instead:
4247 // shaSum := sha256.Sum256(bytes)
4248 // bytes = shaSum[:]
4249 //
4250 SignBytes func(hashBytes []<a href="https://pkg.go.dev/builtin#byte">byte</a>) (signature []<a href="https://pkg.go.dev/builtin#byte">byte</a>, err <a href="https://pkg.go.dev/builtin#error">error</a>)
4251
4252 // SignRawBytes is a function for implementing custom signing. For example, if
4253 // your application is running on Google App Engine, you can use
4254 // appengine's internal signing function:
4255 // ctx := appengine.NewContext(request)
4256 // acc, _ := appengine.ServiceAccount(ctx)
4257 // &PostPolicyV4Options{
4258 // GoogleAccessID: acc,
4259 // SignRawBytes: func(b []byte) ([]byte, error) {
4260 // _, signedBytes, err := appengine.SignBytes(ctx, b)
4261 // return signedBytes, err
4262 // },
4263 // // etc.
4264 // })
4265 //
4266 // SignRawBytes is equivalent to the SignBytes field on SignedURLOptions;
4267 // that is, you may use the same signing function for the two.
4268 //
4269 // Exactly one of PrivateKey or SignRawBytes must be non-nil.
4270 SignRawBytes func(bytes []<a href="https://pkg.go.dev/builtin#byte">byte</a>) (signature []<a href="https://pkg.go.dev/builtin#byte">byte</a>, err <a href="https://pkg.go.dev/builtin#error">error</a>)
4271
4272 // Expires is the expiration time on the signed post policy.
4273 // It must be a time in the future.
4274 // Required.
4275 Expires <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Time">Time</a>
4276
4277 // Style provides options for the type of URL to use. Options are
4278 // PathStyle (default), BucketBoundHostname, and VirtualHostedStyle. See
4279 // https://cloud.google.com/storage/docs/request-endpoints for details.
4280 // Optional.
4281 Style <a href="#cloud_google_com_go_storage_URLStyle">URLStyle</a>
4282
4283 // Insecure when set indicates that the generated URL's scheme
4284 // will use "http" instead of "https" (default).
4285 // Optional.
4286 Insecure <a href="https://pkg.go.dev/builtin#bool">bool</a>
4287
4288 // Fields specifies the attributes of a PostPolicyV4 request.
4289 // When Fields is non-nil, its attributes must match those that will
4290 // passed into field Conditions.
4291 // Optional.
4292 Fields *<a href="#cloud_google_com_go_storage_PolicyV4Fields">PolicyV4Fields</a>
4293
4294 // The conditions that the uploaded file will be expected to conform to.
4295 // When used, the failure of an upload to satisfy a condition will result in
4296 // a 4XX status code, back with the message describing the problem.
4297 // Optional.
4298 Conditions []<a href="#cloud_google_com_go_storage_PostPolicyV4Condition">PostPolicyV4Condition</a>
4299
4300 // Hostname sets the host of the signed post policy. This field overrides
4301 // any endpoint set on a storage Client or through STORAGE_EMULATOR_HOST.
4302 // Only compatible with PathStyle URLStyle.
4303 // Optional.
4304 Hostname <a href="https://pkg.go.dev/builtin#string">string</a>
4305 // contains filtered or unexported fields
4306 }
4307 - uid: cloud.google.com/go/storage.ProjectTeam
4308 name: ProjectTeam
4309 id: ProjectTeam
4310 summary: |
4311 ProjectTeam is the project team associated with the entity, if any.
4312 parent: cloud.google.com/go/storage
4313 type: type
4314 langs:
4315 - go
4316 syntax:
4317 content: |-
4318 type ProjectTeam struct {
4319 ProjectNumber <a href="https://pkg.go.dev/builtin#string">string</a>
4320 Team <a href="https://pkg.go.dev/builtin#string">string</a>
4321 }
4322 - uid: cloud.google.com/go/storage.Projection
4323 name: Projection
4324 id: Projection
4325 summary: |
4326 Projection is enumerated type for Query.Projection.
4327 parent: cloud.google.com/go/storage
4328 type: type
4329 langs:
4330 - go
4331 syntax:
4332 content: type Projection <a href="https://pkg.go.dev/builtin#int">int</a>
4333 - uid: cloud.google.com/go/storage.ProjectionDefault,ProjectionFull,ProjectionNoACL
4334 name: ProjectionDefault, ProjectionFull, ProjectionNoACL
4335 id: ProjectionDefault,ProjectionFull,ProjectionNoACL
4336 parent: cloud.google.com/go/storage.Projection
4337 type: const
4338 langs:
4339 - go
4340 syntax:
4341 content: |-
4342 const (
4343 // ProjectionDefault returns all fields of objects.
4344 ProjectionDefault <a href="#cloud_google_com_go_storage_Projection">Projection</a> = <a href="https://pkg.go.dev/builtin#iota">iota</a>
4345
4346 // ProjectionFull returns all fields of objects.
4347 ProjectionFull
4348
4349 // ProjectionNoACL returns all fields of objects except for Owner and ACL.
4350 ProjectionNoACL
4351 )
4352 - uid: cloud.google.com/go/storage.Projection.String
4353 name: |
4354 func (Projection) String
4355 id: String
4356 parent: cloud.google.com/go/storage.Projection
4357 type: method
4358 langs:
4359 - go
4360 syntax:
4361 content: func (p <a href="#cloud_google_com_go_storage_Projection">Projection</a>) String() <a href="https://pkg.go.dev/builtin#string">string</a>
4362 - uid: cloud.google.com/go/storage.PublicAccessPrevention
4363 name: PublicAccessPrevention
4364 id: PublicAccessPrevention
4365 summary: |
4366 PublicAccessPrevention configures the Public Access Prevention feature, which
4367 can be used to disallow public access to any data in a bucket. See
4368 https://cloud.google.com/storage/docs/public-access-prevention for more
4369 information.
4370 parent: cloud.google.com/go/storage
4371 type: type
4372 langs:
4373 - go
4374 syntax:
4375 content: type PublicAccessPrevention <a href="https://pkg.go.dev/builtin#int">int</a>
4376 - uid: cloud.google.com/go/storage.PublicAccessPreventionUnknown,PublicAccessPreventionUnspecified,PublicAccessPreventionEnforced,PublicAccessPreventionInherited
4377 name: PublicAccessPreventionUnknown, PublicAccessPreventionUnspecified, PublicAccessPreventionEnforced, PublicAccessPreventionInherited
4378 id: PublicAccessPreventionUnknown,PublicAccessPreventionUnspecified,PublicAccessPreventionEnforced,PublicAccessPreventionInherited
4379 parent: cloud.google.com/go/storage.PublicAccessPrevention
4380 type: const
4381 langs:
4382 - go
4383 syntax:
4384 content: |-
4385 const (
4386 // PublicAccessPreventionUnknown is a zero value, used only if this field is
4387 // not set in a call to GCS.
4388 PublicAccessPreventionUnknown <a href="#cloud_google_com_go_storage_PublicAccessPrevention">PublicAccessPrevention</a> = <a href="https://pkg.go.dev/builtin#iota">iota</a>
4389
4390 // PublicAccessPreventionUnspecified corresponds to a value of "unspecified".
4391 // Deprecated: use PublicAccessPreventionInherited
4392 PublicAccessPreventionUnspecified
4393
4394 // PublicAccessPreventionEnforced corresponds to a value of "enforced". This
4395 // enforces Public Access Prevention on the bucket.
4396 PublicAccessPreventionEnforced
4397
4398 // PublicAccessPreventionInherited corresponds to a value of "inherited"
4399 // and is the default for buckets.
4400 PublicAccessPreventionInherited
4401 )
4402 - uid: cloud.google.com/go/storage.PublicAccessPrevention.String
4403 name: |
4404 func (PublicAccessPrevention) String
4405 id: String
4406 parent: cloud.google.com/go/storage.PublicAccessPrevention
4407 type: method
4408 langs:
4409 - go
4410 syntax:
4411 content: func (p <a href="#cloud_google_com_go_storage_PublicAccessPrevention">PublicAccessPrevention</a>) String() <a href="https://pkg.go.dev/builtin#string">string</a>
4412 - uid: cloud.google.com/go/storage.Query
4413 name: Query
4414 id: Query
4415 summary: |
4416 Query represents a query to filter objects from a bucket.
4417 parent: cloud.google.com/go/storage
4418 type: type
4419 langs:
4420 - go
4421 syntax:
4422 content: |-
4423 type Query struct {
4424 // Delimiter returns results in a directory-like fashion.
4425 // Results will contain only objects whose names, aside from the
4426 // prefix, do not contain delimiter. Objects whose names,
4427 // aside from the prefix, contain delimiter will have their name,
4428 // truncated after the delimiter, returned in prefixes.
4429 // Duplicate prefixes are omitted.
4430 // Must be set to / when used with the MatchGlob parameter to filter results
4431 // in a directory-like mode.
4432 // Optional.
4433 Delimiter <a href="https://pkg.go.dev/builtin#string">string</a>
4434
4435 // Prefix is the prefix filter to query objects
4436 // whose names begin with this prefix.
4437 // Optional.
4438 Prefix <a href="https://pkg.go.dev/builtin#string">string</a>
4439
4440 // Versions indicates whether multiple versions of the same
4441 // object will be included in the results.
4442 Versions <a href="https://pkg.go.dev/builtin#bool">bool</a>
4443
4444 // StartOffset is used to filter results to objects whose names are
4445 // lexicographically equal to or after startOffset. If endOffset is also set,
4446 // the objects listed will have names between startOffset (inclusive) and
4447 // endOffset (exclusive).
4448 StartOffset <a href="https://pkg.go.dev/builtin#string">string</a>
4449
4450 // EndOffset is used to filter results to objects whose names are
4451 // lexicographically before endOffset. If startOffset is also set, the objects
4452 // listed will have names between startOffset (inclusive) and endOffset (exclusive).
4453 EndOffset <a href="https://pkg.go.dev/builtin#string">string</a>
4454
4455 // Projection defines the set of properties to return. It will default to ProjectionFull,
4456 // which returns all properties. Passing ProjectionNoACL will omit Owner and ACL,
4457 // which may improve performance when listing many objects.
4458 Projection <a href="#cloud_google_com_go_storage_Projection">Projection</a>
4459
4460 // IncludeTrailingDelimiter controls how objects which end in a single
4461 // instance of Delimiter (for example, if Query.Delimiter = "/" and the
4462 // object name is "foo/bar/") are included in the results. By default, these
4463 // objects only show up as prefixes. If IncludeTrailingDelimiter is set to
4464 // true, they will also be included as objects and their metadata will be
4465 // populated in the returned ObjectAttrs.
4466 IncludeTrailingDelimiter <a href="https://pkg.go.dev/builtin#bool">bool</a>
4467
4468 // MatchGlob is a glob pattern used to filter results (for example, foo*bar). See
4469 // https://cloud.google.com/storage/docs/json_api/v1/objects/list#list-object-glob
4470 // for syntax details. When Delimiter is set in conjunction with MatchGlob,
4471 // it must be set to /.
4472 MatchGlob <a href="https://pkg.go.dev/builtin#string">string</a>
4473 // contains filtered or unexported fields
4474 }
4475 - uid: cloud.google.com/go/storage.Query.SetAttrSelection
4476 name: |
4477 func (*Query) SetAttrSelection
4478 id: SetAttrSelection
4479 summary: |
4480 SetAttrSelection makes the query populate only specific attributes of
4481 objects. When iterating over objects, if you only need each object's name
4482 and size, pass []string{"Name", "Size"} to this method. Only these fields
4483 will be fetched for each object across the network; the other fields of
4484 ObjectAttr will remain at their default values. This is a performance
4485 optimization; for more information, see
4486 https://cloud.google.com/storage/docs/json_api/v1/how-tos/performance
4487 parent: cloud.google.com/go/storage.Query
4488 type: method
4489 langs:
4490 - go
4491 syntax:
4492 content: func (q *<a href="#cloud_google_com_go_storage_Query">Query</a>) SetAttrSelection(attrs []<a href="https://pkg.go.dev/builtin#string">string</a>) <a href="https://pkg.go.dev/builtin#error">error</a>
4493 - uid: cloud.google.com/go/storage.RPO
4494 name: RPO
4495 id: RPO
4496 summary: |
4497 RPO (Recovery Point Objective) configures the turbo replication feature. See
4498 https://cloud.google.com/storage/docs/managing-turbo-replication for more information.
4499 parent: cloud.google.com/go/storage
4500 type: type
4501 langs:
4502 - go
4503 syntax:
4504 content: type RPO <a href="https://pkg.go.dev/builtin#int">int</a>
4505 - uid: cloud.google.com/go/storage.RPOUnknown,RPODefault,RPOAsyncTurbo
4506 name: RPOUnknown, RPODefault, RPOAsyncTurbo
4507 id: RPOUnknown,RPODefault,RPOAsyncTurbo
4508 parent: cloud.google.com/go/storage.RPO
4509 type: const
4510 langs:
4511 - go
4512 syntax:
4513 content: |-
4514 const (
4515 // RPOUnknown is a zero value. It may be returned from bucket.Attrs() if RPO
4516 // is not present in the bucket metadata, that is, the bucket is not dual-region.
4517 // This value is also used if the RPO field is not set in a call to GCS.
4518 RPOUnknown <a href="#cloud_google_com_go_storage_RPO">RPO</a> = <a href="https://pkg.go.dev/builtin#iota">iota</a>
4519
4520 // RPODefault represents default replication. It is used to reset RPO on an
4521 // existing bucket that has this field set to RPOAsyncTurbo. Otherwise it
4522 // is equivalent to RPOUnknown, and is always ignored. This value is valid
4523 // for dual- or multi-region buckets.
4524 RPODefault
4525
4526 // RPOAsyncTurbo represents turbo replication and is used to enable Turbo
4527 // Replication on a bucket. This value is only valid for dual-region buckets.
4528 RPOAsyncTurbo
4529 )
4530 - uid: cloud.google.com/go/storage.RPO.String
4531 name: |
4532 func (RPO) String
4533 id: String
4534 parent: cloud.google.com/go/storage.RPO
4535 type: method
4536 langs:
4537 - go
4538 syntax:
4539 content: func (rpo <a href="#cloud_google_com_go_storage_RPO">RPO</a>) String() <a href="https://pkg.go.dev/builtin#string">string</a>
4540 - uid: cloud.google.com/go/storage.Reader
4541 name: Reader
4542 id: Reader
4543 summary: |
4544 Reader reads a Cloud Storage object.
4545 It implements io.Reader.
4546
4547 Typically, a Reader computes the CRC of the downloaded content and compares it to
4548 the stored CRC, returning an error from Read if there is a mismatch. This integrity check
4549 is skipped if transcoding occurs. See https://cloud.google.com/storage/docs/transcoding.
4550 parent: cloud.google.com/go/storage
4551 type: type
4552 langs:
4553 - go
4554 syntax:
4555 content: |-
4556 type Reader struct {
4557 Attrs <a href="#cloud_google_com_go_storage_ReaderObjectAttrs">ReaderObjectAttrs</a>
4558 // contains filtered or unexported fields
4559 }
4560 - uid: cloud.google.com/go/storage.Reader.CacheControl
4561 name: |
4562 func (*Reader) CacheControl
4563 id: CacheControl
4564 summary: |
4565 CacheControl returns the cache control of the object.
4566
4567 Deprecated: use Reader.Attrs.CacheControl.
4568 parent: cloud.google.com/go/storage.Reader
4569 type: method
4570 langs:
4571 - go
4572 syntax:
4573 content: func (r *<a href="#cloud_google_com_go_storage_Reader">Reader</a>) CacheControl() <a href="https://pkg.go.dev/builtin#string">string</a>
4574 status: deprecated
4575 - uid: cloud.google.com/go/storage.Reader.Close
4576 name: |
4577 func (*Reader) Close
4578 id: Close
4579 summary: |
4580 Close closes the Reader. It must be called when done reading.
4581 parent: cloud.google.com/go/storage.Reader
4582 type: method
4583 langs:
4584 - go
4585 syntax:
4586 content: func (r *<a href="#cloud_google_com_go_storage_Reader">Reader</a>) Close() <a href="https://pkg.go.dev/builtin#error">error</a>
4587 - uid: cloud.google.com/go/storage.Reader.ContentEncoding
4588 name: |
4589 func (*Reader) ContentEncoding
4590 id: ContentEncoding
4591 summary: |
4592 ContentEncoding returns the content encoding of the object.
4593
4594 Deprecated: use Reader.Attrs.ContentEncoding.
4595 parent: cloud.google.com/go/storage.Reader
4596 type: method
4597 langs:
4598 - go
4599 syntax:
4600 content: func (r *<a href="#cloud_google_com_go_storage_Reader">Reader</a>) ContentEncoding() <a href="https://pkg.go.dev/builtin#string">string</a>
4601 status: deprecated
4602 - uid: cloud.google.com/go/storage.Reader.ContentType
4603 name: |
4604 func (*Reader) ContentType
4605 id: ContentType
4606 summary: |
4607 ContentType returns the content type of the object.
4608
4609 Deprecated: use Reader.Attrs.ContentType.
4610 parent: cloud.google.com/go/storage.Reader
4611 type: method
4612 langs:
4613 - go
4614 syntax:
4615 content: func (r *<a href="#cloud_google_com_go_storage_Reader">Reader</a>) ContentType() <a href="https://pkg.go.dev/builtin#string">string</a>
4616 status: deprecated
4617 - uid: cloud.google.com/go/storage.Reader.LastModified
4618 name: |
4619 func (*Reader) LastModified
4620 id: LastModified
4621 summary: |
4622 LastModified returns the value of the Last-Modified header.
4623
4624 Deprecated: use Reader.Attrs.LastModified.
4625 parent: cloud.google.com/go/storage.Reader
4626 type: method
4627 langs:
4628 - go
4629 syntax:
4630 content: func (r *<a href="#cloud_google_com_go_storage_Reader">Reader</a>) LastModified() (<a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Time">Time</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)
4631 status: deprecated
4632 - uid: cloud.google.com/go/storage.Reader.Read
4633 name: |
4634 func (*Reader) Read
4635 id: Read
4636 parent: cloud.google.com/go/storage.Reader
4637 type: method
4638 langs:
4639 - go
4640 syntax:
4641 content: func (r *<a href="#cloud_google_com_go_storage_Reader">Reader</a>) Read(p []<a href="https://pkg.go.dev/builtin#byte">byte</a>) (<a href="https://pkg.go.dev/builtin#int">int</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)
4642 - uid: cloud.google.com/go/storage.Reader.Remain
4643 name: |
4644 func (*Reader) Remain
4645 id: Remain
4646 summary: |
4647 Remain returns the number of bytes left to read, or -1 if unknown.
4648 parent: cloud.google.com/go/storage.Reader
4649 type: method
4650 langs:
4651 - go
4652 syntax:
4653 content: func (r *<a href="#cloud_google_com_go_storage_Reader">Reader</a>) Remain() <a href="https://pkg.go.dev/builtin#int64">int64</a>
4654 - uid: cloud.google.com/go/storage.Reader.Size
4655 name: |
4656 func (*Reader) Size
4657 id: Size
4658 summary: |
4659 Size returns the size of the object in bytes.
4660 The returned value is always the same and is not affected by
4661 calls to Read or Close.
4662
4663 Deprecated: use Reader.Attrs.Size.
4664 parent: cloud.google.com/go/storage.Reader
4665 type: method
4666 langs:
4667 - go
4668 syntax:
4669 content: func (r *<a href="#cloud_google_com_go_storage_Reader">Reader</a>) Size() <a href="https://pkg.go.dev/builtin#int64">int64</a>
4670 status: deprecated
4671 - uid: cloud.google.com/go/storage.ReaderObjectAttrs
4672 name: ReaderObjectAttrs
4673 id: ReaderObjectAttrs
4674 summary: |
4675 ReaderObjectAttrs are attributes about the object being read. These are populated
4676 during the New call. This struct only holds a subset of object attributes: to
4677 get the full set of attributes, use ObjectHandle.Attrs.
4678
4679 Each field is read-only.
4680 parent: cloud.google.com/go/storage
4681 type: type
4682 langs:
4683 - go
4684 syntax:
4685 content: |-
4686 type ReaderObjectAttrs struct {
4687 // Size is the length of the object's content.
4688 Size <a href="https://pkg.go.dev/builtin#int64">int64</a>
4689
4690 // StartOffset is the byte offset within the object
4691 // from which reading begins.
4692 // This value is only non-zero for range requests.
4693 StartOffset <a href="https://pkg.go.dev/builtin#int64">int64</a>
4694
4695 // ContentType is the MIME type of the object's content.
4696 ContentType <a href="https://pkg.go.dev/builtin#string">string</a>
4697
4698 // ContentEncoding is the encoding of the object's content.
4699 ContentEncoding <a href="https://pkg.go.dev/builtin#string">string</a>
4700
4701 // CacheControl specifies whether and for how long browser and Internet
4702 // caches are allowed to cache your objects.
4703 CacheControl <a href="https://pkg.go.dev/builtin#string">string</a>
4704
4705 // LastModified is the time that the object was last modified.
4706 LastModified <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Time">Time</a>
4707
4708 // Generation is the generation number of the object's content.
4709 Generation <a href="https://pkg.go.dev/builtin#int64">int64</a>
4710
4711 // Metageneration is the version of the metadata for this object at
4712 // this generation. This field is used for preconditions and for
4713 // detecting changes in metadata. A metageneration number is only
4714 // meaningful in the context of a particular generation of a
4715 // particular object.
4716 Metageneration <a href="https://pkg.go.dev/builtin#int64">int64</a>
4717 }
4718 - uid: cloud.google.com/go/storage.RetentionPolicy
4719 name: RetentionPolicy
4720 id: RetentionPolicy
4721 summary: |
4722 RetentionPolicy enforces a minimum retention time for all objects
4723 contained in the bucket.
4724
4725 Any attempt to overwrite or delete objects younger than the retention
4726 period will result in an error. An unlocked retention policy can be
4727 modified or removed from the bucket via the Update method. A
4728 locked retention policy cannot be removed or shortened in duration
4729 for the lifetime of the bucket.
4730
4731 This feature is in private alpha release. It is not currently available to
4732 most customers. It might be changed in backwards-incompatible ways and is not
4733 subject to any SLA or deprecation policy.
4734 parent: cloud.google.com/go/storage
4735 type: type
4736 langs:
4737 - go
4738 syntax:
4739 content: |-
4740 type RetentionPolicy struct {
4741 // RetentionPeriod specifies the duration that objects need to be
4742 // retained. Retention duration must be greater than zero and less than
4743 // 100 years. Note that enforcement of retention periods less than a day
4744 // is not guaranteed. Such periods should only be used for testing
4745 // purposes.
4746 RetentionPeriod <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Duration">Duration</a>
4747
4748 // EffectiveTime is the time from which the policy was enforced and
4749 // effective. This field is read-only.
4750 EffectiveTime <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Time">Time</a>
4751
4752 // IsLocked describes whether the bucket is locked. Once locked, an
4753 // object retention policy cannot be modified.
4754 // This field is read-only.
4755 IsLocked <a href="https://pkg.go.dev/builtin#bool">bool</a>
4756 }
4757 - uid: cloud.google.com/go/storage.RetryOption
4758 name: RetryOption
4759 id: RetryOption
4760 summary: |
4761 RetryOption allows users to configure non-default retry behavior for API
4762 calls made to GCS.
4763 parent: cloud.google.com/go/storage
4764 type: type
4765 langs:
4766 - go
4767 syntax:
4768 content: |-
4769 type RetryOption interface {
4770 // contains filtered or unexported methods
4771 }
4772 - uid: cloud.google.com/go/storage.RetryOption.WithBackoff
4773 name: |
4774 func WithBackoff
4775 id: WithBackoff
4776 summary: |
4777 WithBackoff allows configuration of the backoff timing used for retries.
4778 Available configuration options (Initial, Max and Multiplier) are described
4779 at https://pkg.go.dev/github.com/googleapis/gax-go/v2#Backoff. If any fields
4780 are not supplied by the user, gax default values will be used.
4781 parent: cloud.google.com/go/storage.RetryOption
4782 type: function
4783 langs:
4784 - go
4785 syntax:
4786 content: func WithBackoff(backoff <a href="https://pkg.go.dev/github.com/googleapis/gax-go/v2">gax</a>.<a href="https://pkg.go.dev/github.com/googleapis/gax-go/v2#Backoff">Backoff</a>) <a href="#cloud_google_com_go_storage_RetryOption">RetryOption</a>
4787 - uid: cloud.google.com/go/storage.RetryOption.WithErrorFunc
4788 name: |
4789 func WithErrorFunc
4790 id: WithErrorFunc
4791 summary: |
4792 WithErrorFunc allows users to pass a custom function to the retryer. Errors
4793 will be retried if and only if `shouldRetry(err)` returns true.
4794 By default, the following errors are retried (see ShouldRetry for the default
4795 function):
4796
4797 - HTTP responses with codes 408, 429, 502, 503, and 504.
4798
4799 - Transient network errors such as connection reset and io.ErrUnexpectedEOF.
4800
4801 - Errors which are considered transient using the Temporary() interface.
4802
4803 - Wrapped versions of these errors.
4804
4805 This option can be used to retry on a different set of errors than the
4806 default. Users can use the default ShouldRetry function inside their custom
4807 function if they only want to make minor modifications to default behavior.
4808 parent: cloud.google.com/go/storage.RetryOption
4809 type: function
4810 langs:
4811 - go
4812 syntax:
4813 content: func WithErrorFunc(shouldRetry func(err <a href="https://pkg.go.dev/builtin#error">error</a>) <a href="https://pkg.go.dev/builtin#bool">bool</a>) <a href="#cloud_google_com_go_storage_RetryOption">RetryOption</a>
4814 - uid: cloud.google.com/go/storage.RetryOption.WithPolicy
4815 name: |
4816 func WithPolicy
4817 id: WithPolicy
4818 summary: |
4819 WithPolicy allows the configuration of which operations should be performed
4820 with retries for transient errors.
4821 parent: cloud.google.com/go/storage.RetryOption
4822 type: function
4823 langs:
4824 - go
4825 syntax:
4826 content: func WithPolicy(policy <a href="#cloud_google_com_go_storage_RetryPolicy">RetryPolicy</a>) <a href="#cloud_google_com_go_storage_RetryOption">RetryOption</a>
4827 - uid: cloud.google.com/go/storage.RetryPolicy
4828 name: RetryPolicy
4829 id: RetryPolicy
4830 summary: |
4831 RetryPolicy describes the available policies for which operations should be
4832 retried. The default is `RetryIdempotent`.
4833 parent: cloud.google.com/go/storage
4834 type: type
4835 langs:
4836 - go
4837 syntax:
4838 content: type RetryPolicy <a href="https://pkg.go.dev/builtin#int">int</a>
4839 - uid: cloud.google.com/go/storage.RetryIdempotent,RetryAlways,RetryNever
4840 name: RetryIdempotent, RetryAlways, RetryNever
4841 id: RetryIdempotent,RetryAlways,RetryNever
4842 parent: cloud.google.com/go/storage.RetryPolicy
4843 type: const
4844 langs:
4845 - go
4846 syntax:
4847 content: |-
4848 const (
4849 // RetryIdempotent causes only idempotent operations to be retried when the
4850 // service returns a transient error. Using this policy, fully idempotent
4851 // operations (such as `ObjectHandle.Attrs()`) will always be retried.
4852 // Conditionally idempotent operations (for example `ObjectHandle.Update()`)
4853 // will be retried only if the necessary conditions have been supplied (in
4854 // the case of `ObjectHandle.Update()` this would mean supplying a
4855 // `Conditions.MetagenerationMatch` condition is required).
4856 RetryIdempotent <a href="#cloud_google_com_go_storage_RetryPolicy">RetryPolicy</a> = <a href="https://pkg.go.dev/builtin#iota">iota</a>
4857
4858 // RetryAlways causes all operations to be retried when the service returns a
4859 // transient error, regardless of idempotency considerations.
4860 RetryAlways
4861
4862 // RetryNever causes the client to not perform retries on failed operations.
4863 RetryNever
4864 )
4865 - uid: cloud.google.com/go/storage.SignedURLOptions
4866 name: SignedURLOptions
4867 id: SignedURLOptions
4868 summary: |
4869 SignedURLOptions allows you to restrict the access to the signed URL.
4870 parent: cloud.google.com/go/storage
4871 type: type
4872 langs:
4873 - go
4874 syntax:
4875 content: |-
4876 type SignedURLOptions struct {
4877 // GoogleAccessID represents the authorizer of the signed URL generation.
4878 // It is typically the Google service account client email address from
4879 // the Google Developers Console in the form of "[email protected]".
4880 // Required.
4881 GoogleAccessID <a href="https://pkg.go.dev/builtin#string">string</a>
4882
4883 // PrivateKey is the Google service account private key. It is obtainable
4884 // from the Google Developers Console.
4885 // At https://console.developers.google.com/project/<your-project-id>/apiui/credential,
4886 // create a service account client ID or reuse one of your existing service account
4887 // credentials. Click on the "Generate new P12 key" to generate and download
4888 // a new private key. Once you download the P12 file, use the following command
4889 // to convert it into a PEM file.
4890 //
4891 // $ openssl pkcs12 -in key.p12 -passin pass:notasecret -out key.pem -nodes
4892 //
4893 // Provide the contents of the PEM file as a byte slice.
4894 // Exactly one of PrivateKey or SignBytes must be non-nil.
4895 PrivateKey []<a href="https://pkg.go.dev/builtin#byte">byte</a>
4896
4897 // SignBytes is a function for implementing custom signing. For example, if
4898 // your application is running on Google App Engine, you can use
4899 // appengine's internal signing function:
4900 // ctx := appengine.NewContext(request)
4901 // acc, _ := appengine.ServiceAccount(ctx)
4902 // url, err := SignedURL("bucket", "object", &SignedURLOptions{
4903 // GoogleAccessID: acc,
4904 // SignBytes: func(b []byte) ([]byte, error) {
4905 // _, signedBytes, err := appengine.SignBytes(ctx, b)
4906 // return signedBytes, err
4907 // },
4908 // // etc.
4909 // })
4910 //
4911 // Exactly one of PrivateKey or SignBytes must be non-nil.
4912 SignBytes func([]<a href="https://pkg.go.dev/builtin#byte">byte</a>) ([]<a href="https://pkg.go.dev/builtin#byte">byte</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)
4913
4914 // Method is the HTTP method to be used with the signed URL.
4915 // Signed URLs can be used with GET, HEAD, PUT, and DELETE requests.
4916 // Required.
4917 Method <a href="https://pkg.go.dev/builtin#string">string</a>
4918
4919 // Expires is the expiration time on the signed URL. It must be
4920 // a datetime in the future. For SigningSchemeV4, the expiration may be no
4921 // more than seven days in the future.
4922 // Required.
4923 Expires <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Time">Time</a>
4924
4925 // ContentType is the content type header the client must provide
4926 // to use the generated signed URL.
4927 // Optional.
4928 ContentType <a href="https://pkg.go.dev/builtin#string">string</a>
4929
4930 // Headers is a list of extension headers the client must provide
4931 // in order to use the generated signed URL. Each must be a string of the
4932 // form "key:values", with multiple values separated by a semicolon.
4933 // Optional.
4934 Headers []<a href="https://pkg.go.dev/builtin#string">string</a>
4935
4936 // QueryParameters is a map of additional query parameters. When
4937 // SigningScheme is V4, this is used in computing the signature, and the
4938 // client must use the same query parameters when using the generated signed
4939 // URL.
4940 // Optional.
4941 QueryParameters <a href="https://pkg.go.dev/net/url">url</a>.<a href="https://pkg.go.dev/net/url#Values">Values</a>
4942
4943 // MD5 is the base64 encoded MD5 checksum of the file.
4944 // If provided, the client should provide the exact value on the request
4945 // header in order to use the signed URL.
4946 // Optional.
4947 MD5 <a href="https://pkg.go.dev/builtin#string">string</a>
4948
4949 // Style provides options for the type of URL to use. Options are
4950 // PathStyle (default), BucketBoundHostname, and VirtualHostedStyle. See
4951 // https://cloud.google.com/storage/docs/request-endpoints for details.
4952 // Only supported for V4 signing.
4953 // Optional.
4954 Style <a href="#cloud_google_com_go_storage_URLStyle">URLStyle</a>
4955
4956 // Insecure determines whether the signed URL should use HTTPS (default) or
4957 // HTTP.
4958 // Only supported for V4 signing.
4959 // Optional.
4960 Insecure <a href="https://pkg.go.dev/builtin#bool">bool</a>
4961
4962 // Scheme determines the version of URL signing to use. Default is
4963 // SigningSchemeV2.
4964 Scheme <a href="#cloud_google_com_go_storage_SigningScheme">SigningScheme</a>
4965
4966 // Hostname sets the host of the signed URL. This field overrides any
4967 // endpoint set on a storage Client or through STORAGE_EMULATOR_HOST.
4968 // Only compatible with PathStyle URLStyle.
4969 // Optional.
4970 Hostname <a href="https://pkg.go.dev/builtin#string">string</a>
4971 }
4972 - uid: cloud.google.com/go/storage.SigningScheme
4973 name: SigningScheme
4974 id: SigningScheme
4975 summary: |
4976 SigningScheme determines the API version to use when signing URLs.
4977 parent: cloud.google.com/go/storage
4978 type: type
4979 langs:
4980 - go
4981 syntax:
4982 content: type SigningScheme <a href="https://pkg.go.dev/builtin#int">int</a>
4983 - uid: cloud.google.com/go/storage.SigningSchemeDefault,SigningSchemeV2,SigningSchemeV4
4984 name: SigningSchemeDefault, SigningSchemeV2, SigningSchemeV4
4985 id: SigningSchemeDefault,SigningSchemeV2,SigningSchemeV4
4986 parent: cloud.google.com/go/storage.SigningScheme
4987 type: const
4988 langs:
4989 - go
4990 syntax:
4991 content: |-
4992 const (
4993 // SigningSchemeDefault is presently V2 and will change to V4 in the future.
4994 SigningSchemeDefault <a href="#cloud_google_com_go_storage_SigningScheme">SigningScheme</a> = <a href="https://pkg.go.dev/builtin#iota">iota</a>
4995
4996 // SigningSchemeV2 uses the V2 scheme to sign URLs.
4997 SigningSchemeV2
4998
4999 // SigningSchemeV4 uses the V4 scheme to sign URLs.
5000 SigningSchemeV4
5001 )
5002 - uid: cloud.google.com/go/storage.URLStyle
5003 name: URLStyle
5004 id: URLStyle
5005 summary: |
5006 URLStyle determines the style to use for the signed URL. PathStyle is the
5007 default. All non-default options work with V4 scheme only. See
5008 https://cloud.google.com/storage/docs/request-endpoints for details.
5009 parent: cloud.google.com/go/storage
5010 type: type
5011 langs:
5012 - go
5013 syntax:
5014 content: |-
5015 type URLStyle interface {
5016 // contains filtered or unexported methods
5017 }
5018 - uid: cloud.google.com/go/storage.URLStyle.BucketBoundHostname
5019 name: |
5020 func BucketBoundHostname
5021 id: BucketBoundHostname
5022 summary: |
5023 BucketBoundHostname generates a URL with a custom hostname tied to a
5024 specific GCS bucket. The desired hostname should be passed in using the
5025 hostname argument. Generated urls will be of the form
5026 "<bucket-bound-hostname>/<object-name>". See
5027 https://cloud.google.com/storage/docs/request-endpoints#cname and
5028 https://cloud.google.com/load-balancing/docs/https/adding-backend-buckets-to-load-balancers
5029 for details. Note that for CNAMEs, only HTTP is supported, so Insecure must
5030 be set to true.
5031 parent: cloud.google.com/go/storage.URLStyle
5032 type: function
5033 langs:
5034 - go
5035 syntax:
5036 content: func BucketBoundHostname(hostname <a href="https://pkg.go.dev/builtin#string">string</a>) <a href="#cloud_google_com_go_storage_URLStyle">URLStyle</a>
5037 - uid: cloud.google.com/go/storage.URLStyle.PathStyle
5038 name: |
5039 func PathStyle
5040 id: PathStyle
5041 summary: |
5042 PathStyle is the default style, and will generate a URL of the form
5043 "<host-name>/<bucket-name>/<object-name>". By default, <host-name> is
5044 storage.googleapis.com, but setting an endpoint on the storage Client or
5045 through STORAGE_EMULATOR_HOST overrides this. Setting Hostname on
5046 SignedURLOptions or PostPolicyV4Options overrides everything else.
5047 parent: cloud.google.com/go/storage.URLStyle
5048 type: function
5049 langs:
5050 - go
5051 syntax:
5052 content: func PathStyle() <a href="#cloud_google_com_go_storage_URLStyle">URLStyle</a>
5053 - uid: cloud.google.com/go/storage.URLStyle.VirtualHostedStyle
5054 name: |
5055 func VirtualHostedStyle
5056 id: VirtualHostedStyle
5057 summary: |
5058 VirtualHostedStyle generates a URL relative to the bucket's virtual
5059 hostname, e.g. "<bucket-name>.storage.googleapis.com/<object-name>".
5060 parent: cloud.google.com/go/storage.URLStyle
5061 type: function
5062 langs:
5063 - go
5064 syntax:
5065 content: func VirtualHostedStyle() <a href="#cloud_google_com_go_storage_URLStyle">URLStyle</a>
5066 - uid: cloud.google.com/go/storage.UniformBucketLevelAccess
5067 name: UniformBucketLevelAccess
5068 id: UniformBucketLevelAccess
5069 summary: |
5070 UniformBucketLevelAccess configures access checks to use only bucket-level IAM
5071 policies.
5072 parent: cloud.google.com/go/storage
5073 type: type
5074 langs:
5075 - go
5076 syntax:
5077 content: |-
5078 type UniformBucketLevelAccess struct {
5079 // Enabled specifies whether access checks use only bucket-level IAM
5080 // policies. Enabled may be disabled until the locked time.
5081 Enabled <a href="https://pkg.go.dev/builtin#bool">bool</a>
5082 // LockedTime specifies the deadline for changing Enabled from true to
5083 // false.
5084 LockedTime <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Time">Time</a>
5085 }
5086 - uid: cloud.google.com/go/storage.Writer
5087 name: Writer
5088 id: Writer
5089 summary: |
5090 A Writer writes a Cloud Storage object.
5091 parent: cloud.google.com/go/storage
5092 type: type
5093 langs:
5094 - go
5095 syntax:
5096 content: |-
5097 type Writer struct {
5098 // ObjectAttrs are optional attributes to set on the object. Any attributes
5099 // must be initialized before the first Write call. Nil or zero-valued
5100 // attributes are ignored.
5101 <a href="#cloud_google_com_go_storage_ObjectAttrs">ObjectAttrs</a>
5102
5103 // SendCRC32C specifies whether to transmit a CRC32C field. It should be set
5104 // to true in addition to setting the Writer's CRC32C field, because zero
5105 // is a valid CRC and normally a zero would not be transmitted.
5106 // If a CRC32C is sent, and the data written does not match the checksum,
5107 // the write will be rejected.
5108 //
5109 // Note: SendCRC32C must be set to true BEFORE the first call to
5110 // Writer.Write() in order to send the checksum. If it is set after that
5111 // point, the checksum will be ignored.
5112 SendCRC32C <a href="https://pkg.go.dev/builtin#bool">bool</a>
5113
5114 // ChunkSize controls the maximum number of bytes of the object that the
5115 // Writer will attempt to send to the server in a single request. Objects
5116 // smaller than the size will be sent in a single request, while larger
5117 // objects will be split over multiple requests. The value will be rounded up
5118 // to the nearest multiple of 256K. The default ChunkSize is 16MiB.
5119 //
5120 // Each Writer will internally allocate a buffer of size ChunkSize. This is
5121 // used to buffer input data and allow for the input to be sent again if a
5122 // request must be retried.
5123 //
5124 // If you upload small objects (< 16MiB), you should set ChunkSize
5125 // to a value slightly larger than the objects' sizes to avoid memory bloat.
5126 // This is especially important if you are uploading many small objects
5127 // concurrently. See
5128 // https://cloud.google.com/storage/docs/json_api/v1/how-tos/upload#size
5129 // for more information about performance trade-offs related to ChunkSize.
5130 //
5131 // If ChunkSize is set to zero, chunking will be disabled and the object will
5132 // be uploaded in a single request without the use of a buffer. This will
5133 // further reduce memory used during uploads, but will also prevent the writer
5134 // from retrying in case of a transient error from the server or resuming an
5135 // upload that fails midway through, since the buffer is required in order to
5136 // retry the failed request.
5137 //
5138 // ChunkSize must be set before the first Write call.
5139 ChunkSize <a href="https://pkg.go.dev/builtin#int">int</a>
5140
5141 // ChunkRetryDeadline sets a per-chunk retry deadline for multi-chunk
5142 // resumable uploads.
5143 //
5144 // For uploads of larger files, the Writer will attempt to retry if the
5145 // request to upload a particular chunk fails with a transient error.
5146 // If a single chunk has been attempting to upload for longer than this
5147 // deadline and the request fails, it will no longer be retried, and the error
5148 // will be returned to the caller. This is only applicable for files which are
5149 // large enough to require a multi-chunk resumable upload. The default value
5150 // is 32s. Users may want to pick a longer deadline if they are using larger
5151 // values for ChunkSize or if they expect to have a slow or unreliable
5152 // internet connection.
5153 //
5154 // To set a deadline on the entire upload, use context timeout or
5155 // cancellation.
5156 ChunkRetryDeadline <a href="https://pkg.go.dev/time">time</a>.<a href="https://pkg.go.dev/time#Duration">Duration</a>
5157
5158 // ProgressFunc can be used to monitor the progress of a large write
5159 // operation. If ProgressFunc is not nil and writing requires multiple
5160 // calls to the underlying service (see
5161 // https://cloud.google.com/storage/docs/json_api/v1/how-tos/resumable-upload),
5162 // then ProgressFunc will be invoked after each call with the number of bytes of
5163 // content copied so far.
5164 //
5165 // ProgressFunc should return quickly without blocking.
5166 ProgressFunc func(<a href="https://pkg.go.dev/builtin#int64">int64</a>)
5167 // contains filtered or unexported fields
5168 }
5169 - uid: cloud.google.com/go/storage.Writer.Attrs
5170 name: |
5171 func (*Writer) Attrs
5172 id: Attrs
5173 summary: |
5174 Attrs returns metadata about a successfully-written object.
5175 It's only valid to call it after Close returns nil.
5176 parent: cloud.google.com/go/storage.Writer
5177 type: method
5178 langs:
5179 - go
5180 syntax:
5181 content: func (w *<a href="#cloud_google_com_go_storage_Writer">Writer</a>) Attrs() *<a href="#cloud_google_com_go_storage_ObjectAttrs">ObjectAttrs</a>
5182 - uid: cloud.google.com/go/storage.Writer.Close
5183 name: |
5184 func (*Writer) Close
5185 id: Close
5186 summary: |
5187 Close completes the write operation and flushes any buffered data.
5188 If Close doesn't return an error, metadata about the written object
5189 can be retrieved by calling Attrs.
5190 parent: cloud.google.com/go/storage.Writer
5191 type: method
5192 langs:
5193 - go
5194 syntax:
5195 content: func (w *<a href="#cloud_google_com_go_storage_Writer">Writer</a>) Close() <a href="https://pkg.go.dev/builtin#error">error</a>
5196 - uid: cloud.google.com/go/storage.Writer.CloseWithError
5197 name: |
5198 func (*Writer) CloseWithError
5199 id: CloseWithError
5200 summary: |
5201 CloseWithError aborts the write operation with the provided error.
5202 CloseWithError always returns nil.
5203
5204 Deprecated: cancel the context passed to NewWriter instead.
5205 parent: cloud.google.com/go/storage.Writer
5206 type: method
5207 langs:
5208 - go
5209 syntax:
5210 content: func (w *<a href="#cloud_google_com_go_storage_Writer">Writer</a>) CloseWithError(err <a href="https://pkg.go.dev/builtin#error">error</a>) <a href="https://pkg.go.dev/builtin#error">error</a>
5211 status: deprecated
5212 - uid: cloud.google.com/go/storage.Writer.Write
5213 name: |
5214 func (*Writer) Write
5215 id: Write
5216 summary: |
5217 Write appends to w. It implements the io.Writer interface.
5218
5219 Since writes happen asynchronously, Write may return a nil
5220 error even though the write failed (or will fail). Always
5221 use the error returned from Writer.Close to determine if
5222 the upload was successful.
5223
5224 Writes will be retried on transient errors from the server, unless
5225 Writer.ChunkSize has been set to zero.
5226 parent: cloud.google.com/go/storage.Writer
5227 type: method
5228 langs:
5229 - go
5230 syntax:
5231 content: func (w *<a href="#cloud_google_com_go_storage_Writer">Writer</a>) Write(p []<a href="https://pkg.go.dev/builtin#byte">byte</a>) (n <a href="https://pkg.go.dev/builtin#int">int</a>, err <a href="https://pkg.go.dev/builtin#error">error</a>)
5232 codeexamples:
5233 - content: |
5234 package main
5235
5236 import (
5237 "context"
5238 "fmt"
5239
5240 "cloud.google.com/go/storage"
5241 )
5242
5243 func main() {
5244 ctx := context.Background()
5245 client, err := storage.NewClient(ctx)
5246 if err != nil {
5247 // TODO: handle error.
5248 }
5249 wc := client.Bucket("bucketname").Object("filename1").NewWriter(ctx)
5250 wc.ContentType = "text/plain"
5251 wc.ACL = []storage.ACLRule{{Entity: storage.AllUsers, Role: storage.RoleReader}}
5252 if _, err := wc.Write([]byte("hello world")); err != nil {
5253 // TODO: handle error.
5254 // Note that Write may return nil in some error situations,
5255 // so always check the error from Close.
5256 }
5257 if err := wc.Close(); err != nil {
5258 // TODO: handle error.
5259 }
5260 fmt.Println("updated object:", wc.Attrs())
5261 }
5262 - content: |
5263 package main
5264
5265 import (
5266 "context"
5267 "fmt"
5268 "hash/crc32"
5269
5270 "cloud.google.com/go/storage"
5271 )
5272
5273 func main() {
5274 ctx := context.Background()
5275 client, err := storage.NewClient(ctx)
5276 if err != nil {
5277 // TODO: handle error.
5278 }
5279 data := []byte("verify me")
5280 wc := client.Bucket("bucketname").Object("filename1").NewWriter(ctx)
5281 wc.CRC32C = crc32.Checksum(data, crc32.MakeTable(crc32.Castagnoli))
5282 wc.SendCRC32C = true
5283 if _, err := wc.Write([]byte("hello world")); err != nil {
5284 // TODO: handle error.
5285 // Note that Write may return nil in some error situations,
5286 // so always check the error from Close.
5287 }
5288 if err := wc.Close(); err != nil {
5289 // TODO: handle error.
5290 }
5291 fmt.Println("updated object:", wc.Attrs())
5292 }
5293 name: checksum
5294 - content: |
5295 package main
5296
5297 import (
5298 "context"
5299 "fmt"
5300 "time"
5301
5302 "cloud.google.com/go/storage"
5303 )
5304
5305 func main() {
5306 ctx := context.Background()
5307 client, err := storage.NewClient(ctx)
5308 if err != nil {
5309 // TODO: handle error.
5310 }
5311 tctx, cancel := context.WithTimeout(ctx, 30*time.Second)
5312 defer cancel() // Cancel when done, whether we time out or not.
5313 wc := client.Bucket("bucketname").Object("filename1").NewWriter(tctx)
5314 wc.ContentType = "text/plain"
5315 wc.ACL = []storage.ACLRule{{Entity: storage.AllUsers, Role: storage.RoleReader}}
5316 if _, err := wc.Write([]byte("hello world")); err != nil {
5317 // TODO: handle error.
5318 // Note that Write may return nil in some error situations,
5319 // so always check the error from Close.
5320 }
5321 if err := wc.Close(); err != nil {
5322 // TODO: handle error.
5323 }
5324 fmt.Println("updated object:", wc.Attrs())
5325 }
5326 name: timeout
5327 - uid: cloud.google.com/go/storage.ShouldRetry
5328 name: |
5329 func ShouldRetry
5330 id: ShouldRetry
5331 summary: |
5332 ShouldRetry returns true if an error is retryable, based on best practice
5333 guidance from GCS. See
5334 https://cloud.google.com/storage/docs/retry-strategy#go for more information
5335 on what errors are considered retryable.
5336
5337 If you would like to customize retryable errors, use the WithErrorFunc to
5338 supply a RetryOption to your library calls. For example, to retry additional
5339 errors, you can write a custom func that wraps ShouldRetry and also specifies
5340 additional errors that should return true.
5341 parent: cloud.google.com/go/storage
5342 type: function
5343 langs:
5344 - go
5345 syntax:
5346 content: func ShouldRetry(err <a href="https://pkg.go.dev/builtin#error">error</a>) <a href="https://pkg.go.dev/builtin#bool">bool</a>
5347 - uid: cloud.google.com/go/storage.SignedURL
5348 name: |
5349 func SignedURL
5350 id: SignedURL
5351 summary: |
5352 SignedURL returns a URL for the specified object. Signed URLs allow anyone
5353 access to a restricted resource for a limited time without needing a
5354 Google account or signing in. For more information about signed URLs, see
5355 https://cloud.google.com/storage/docs/accesscontrol#signed_urls_query_string_authentication
5356 If initializing a Storage Client, instead use the Bucket.SignedURL method
5357 which uses the Client's credentials to handle authentication.
5358 parent: cloud.google.com/go/storage
5359 type: function
5360 langs:
5361 - go
5362 syntax:
5363 content: func SignedURL(bucket, object <a href="https://pkg.go.dev/builtin#string">string</a>, opts *<a href="#cloud_google_com_go_storage_SignedURLOptions">SignedURLOptions</a>) (<a href="https://pkg.go.dev/builtin#string">string</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)
5364 codeexamples:
5365 - content: |
5366 package main
5367
5368 import (
5369 "fmt"
5370 "io/ioutil"
5371 "time"
5372
5373 "cloud.google.com/go/storage"
5374 )
5375
5376 func main() {
5377 pkey, err := ioutil.ReadFile("my-private-key.pem")
5378 if err != nil {
5379 // TODO: handle error.
5380 }
5381 url, err := storage.SignedURL("my-bucket", "my-object", &storage.SignedURLOptions{
5382 GoogleAccessID: "[email protected]",
5383 PrivateKey: pkey,
5384 Method: "GET",
5385 Expires: time.Now().Add(48 * time.Hour),
5386 })
5387 if err != nil {
5388 // TODO: handle error.
5389 }
5390 fmt.Println(url)
5391 }
5392 - uid: cloud.google.com/go/storage.WithJSONReads
5393 name: |
5394 func WithJSONReads
5395 id: WithJSONReads
5396 summary: |
5397 WithJSONReads is an option that may be passed to a Storage Client on creation.
5398 It sets the client to use the JSON API for object reads. Currently, the
5399 default API used for reads is XML.
5400 Setting this option is required to use the GenerationNotMatch condition.
5401
5402 Note that when this option is set, reads will return a zero date for
5403 [ReaderObjectAttrs].LastModified and may return a different value for
5404 [ReaderObjectAttrs].CacheControl.
5405 parent: cloud.google.com/go/storage
5406 type: function
5407 langs:
5408 - go
5409 syntax:
5410 content: func WithJSONReads() <a href="https://pkg.go.dev/google.golang.org/api/option">option</a>.<a href="https://pkg.go.dev/google.golang.org/api/option#ClientOption">ClientOption</a>
5411 - uid: cloud.google.com/go/storage.WithXMLReads
5412 name: |
5413 func WithXMLReads
5414 id: WithXMLReads
5415 summary: |
5416 WithXMLReads is an option that may be passed to a Storage Client on creation.
5417 It sets the client to use the XML API for object reads.
5418
5419 This is the current default.
5420 parent: cloud.google.com/go/storage
5421 type: function
5422 langs:
5423 - go
5424 syntax:
5425 content: func WithXMLReads() <a href="https://pkg.go.dev/google.golang.org/api/option">option</a>.<a href="https://pkg.go.dev/google.golang.org/api/option#ClientOption">ClientOption</a>