Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(904)

Side by Side Diff: third_party/gsutil/gslib/addlhelp/metadata.py

Issue 1380943003: Roll version of gsutil to 4.15. (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/gsutil/gslib/addlhelp/crc32c.py ('k') | third_party/gsutil/gslib/addlhelp/prod.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 # Copyright 2012 Google Inc. All Rights Reserved. 2 # Copyright 2012 Google Inc. All Rights Reserved.
3 # 3 #
4 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License. 5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at 6 # You may obtain a copy of the License at
7 # 7 #
8 # http://www.apache.org/licenses/LICENSE-2.0 8 # http://www.apache.org/licenses/LICENSE-2.0
9 # 9 #
10 # Unless required by applicable law or agreed to in writing, software 10 # Unless required by applicable law or agreed to in writing, software
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 ".webp" was recognized by the server-side content detection system, but 78 ".webp" was recognized by the server-side content detection system, but
79 not by gsutil.) 79 not by gsutil.)
80 80
81 81
82 <B>CACHE-CONTROL</B> 82 <B>CACHE-CONTROL</B>
83 Another commonly set piece of metadata is Cache-Control, which allows 83 Another commonly set piece of metadata is Cache-Control, which allows
84 you to control whether and for how long browser and Internet caches are 84 you to control whether and for how long browser and Internet caches are
85 allowed to cache your objects. Cache-Control only applies to objects with 85 allowed to cache your objects. Cache-Control only applies to objects with
86 a public-read ACL. Non-public data are not cacheable. 86 a public-read ACL. Non-public data are not cacheable.
87 87
88 Here's an example of uploading an object set to allow caching: 88 Here's an example of uploading a set of objects to allow caching:
89 89
90 gsutil -h "Cache-Control:public,max-age=3600" cp -a public-read \\ 90 gsutil -h "Cache-Control:public,max-age=3600" cp -a public-read \\
91 -r html gs://bucket/html 91 -r html gs://bucket/html
92 92
93 This command would upload all files in the html directory (and subdirectories) 93 This command would upload all files in the html directory (and subdirectories)
94 and make them publicly readable and cacheable, with cache expiration of 94 and make them publicly readable and cacheable, with cache expiration of
95 one hour. 95 one hour.
96 96
97 Note that if you allow caching, at download time you may see older versions 97 Note that if you allow caching, at download time you may see older versions
98 of objects after uploading a newer replacement object. Note also that because 98 of objects after uploading a newer replacement object. Note also that because
99 objects can be cached at various places on the Internet there is no way to 99 objects can be cached at various places on the Internet there is no way to
100 force a cached object to expire globally (unlike the way you can force your 100 force a cached object to expire globally (unlike the way you can force your
101 browser to refresh its cache). 101 browser to refresh its cache). If you want to prevent caching of publicly
102 readable objects you should set a Cache-Control:private header on the object.
103 You can do this with a command such as:
104
105 gsutil -h Cache-Control:private cp -a public-read file.png gs://your-bucket
102 106
103 Another use of the Cache-Control header is through the "no-transform" value, 107 Another use of the Cache-Control header is through the "no-transform" value,
104 which instructs Google Cloud Storage to not apply any content transformations 108 which instructs Google Cloud Storage to not apply any content transformations
105 based on specifics of a download request, such as removing gzip 109 based on specifics of a download request, such as removing gzip
106 content-encoding for incompatible clients. Note that this parameter is only 110 content-encoding for incompatible clients. Note that this parameter is only
107 respected by the XML API. The Google Cloud Storage JSON API respects only the 111 respected by the XML API. The Google Cloud Storage JSON API respects only the
108 no-cache and max-age Cache-Control parameters. 112 no-cache and max-age Cache-Control parameters.
109 113
110 Note that if you upload an object with a public-read ACL and don't include a
111 Cache-Control header, it will be served with a Cache-Control header allowing
112 the object to be cached for 3600 seconds. This will not happen if the object
113 is uploaded with a non-public ACL and then changed to public. Moreover, if you
114 upload an object with a public-read ACL and later change the ACL not to be
115 public-read, the object will no longer be served with the default
116 Cache-Control header noted above (so will be served as not cacheable).
117
118 For details about how to set the Cache-Control header see 114 For details about how to set the Cache-Control header see
119 "gsutil help setmeta". 115 "gsutil help setmeta".
120 116
121 117
122 <B>CONTENT-ENCODING</B> 118 <B>CONTENT-ENCODING</B>
123 You can specify a Content-Encoding to indicate that an object is compressed 119 You can specify a Content-Encoding to indicate that an object is compressed
124 (for example, with gzip compression) while maintaining its Content-Type. 120 (for example, with gzip compression) while maintaining its Content-Type.
125 You will need to ensure that the files have been compressed using the 121 You will need to ensure that the files have been compressed using the
126 specified Content-Encoding before using gsutil to upload them. Consider the 122 specified Content-Encoding before using gsutil to upload them. Consider the
127 following example for Linux: 123 following example for Linux:
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 help_spec = HelpProvider.HelpSpec( 198 help_spec = HelpProvider.HelpSpec(
203 help_name='metadata', 199 help_name='metadata',
204 help_name_aliases=[ 200 help_name_aliases=[
205 'cache-control', 'caching', 'content type', 'mime type', 'mime', 201 'cache-control', 'caching', 'content type', 'mime type', 'mime',
206 'type'], 202 'type'],
207 help_type='additional_help', 203 help_type='additional_help',
208 help_one_line_summary='Working With Object Metadata', 204 help_one_line_summary='Working With Object Metadata',
209 help_text=_DETAILED_HELP_TEXT, 205 help_text=_DETAILED_HELP_TEXT,
210 subcommand_help_text={}, 206 subcommand_help_text={},
211 ) 207 )
OLDNEW
« no previous file with comments | « third_party/gsutil/gslib/addlhelp/crc32c.py ('k') | third_party/gsutil/gslib/addlhelp/prod.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698