Difference between revisions of "Gsutil acl set"

From wikieduonline
Jump to navigation Jump to search
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{{lc}}
 
{{lc}}
[[gsutil acl]] set
+
https://cloud.google.com/storage/docs/gsutil/commands/acl#set
=== Set ===
+
* <code>[[gsutil acl]] set</code>
 +
* <code>[[gsutil acl set private]]</code>
  
The "acl set" command allows you to set an Access Control List on one or more buckets and objects. The file-or-canned_acl_name parameter names either a canned ACL or the path to a file that contains ACL text. The simplest way to use the "acl set" command is to specify one of the canned ACLs, e.g.,:
 
  
* <code>gsutil acl set private gs://bucket</code>
+
== Related ==
 
+
* [[Predefined ACLs]]
If you want to make an object or bucket publicly readable or writable, it is recommended to use "acl ch", to avoid accidentally removing OWNER permissions. See the "acl ch" section for details.
+
* <code>[[gsutil acl get]]</code>
 
+
* <code>[[gsutil ubla set]]</code>
See Predefined ACLs for a list of canned ACLs.
+
* <code>[[gsutil acl ch]]</code>
 
 
If you want to define more fine-grained control over your data, you can retrieve an ACL using the "acl get" command, save the output to a file, edit the file, and then use the "acl set" command to set that ACL on the buckets and/or objects. For example:
 
 
 
 
 
* <code>gsutil acl get gs://bucket/file.txt > acl.txt</code>
 
 
 
Make changes to acl.txt such as adding an additional grant, then:
 
 
 
* <code>gsutil acl set acl.txt gs://cats/file.txt</code>
 
 
 
Note that you can set an ACL on multiple buckets or objects at once. For example, to set ACLs on all .jpg files found in a bucket:
 
 
 
* <code>gsutil acl set acl.txt gs://bucket/**.jpg</code>
 
If you have a large number of ACLs to update you might want to use the gsutil -m option, to perform a parallel (multi-threaded/multi-processing) update:
 
 
 
* <code>gsutil -m acl set acl.txt gs://bucket/**.jpg</code>
 
 
 
Note that multi-threading/multi-processing is only done when the named URLs refer to objects, which happens either if you name specific objects or if you enumerate objects by using an object wildcard or specifying the acl -r flag.
 
 
 
===Set Options===
 
 
 
The "set" sub-command has the following options
 
 
 
*<code>-R, -r</code>
 
Performs "acl set" request recursively, to all objects under the specified URL.
 
 
 
*<code>-a</code>
 
Performs "acl set" request on all object versions.
 
 
 
*<code>-f</code>
 
Normally gsutil stops at the first error. The -f option causes it to continue when it encounters errors. If some of the ACLs couldn't be set, gsutil's exit status will be non-zero even if this flag is set. This option is implicitly set when running "gsutil -m acl...".
 
 
 
[[gsutil acl set private]]
 
  
 
== See also ==
 
== See also ==

Latest revision as of 18:10, 3 August 2022

Advertising: