|
@@ -171,6 +171,10 @@ def main():
|
|
parser.add_option('-b',
|
|
parser.add_option('-b',
|
|
'--bucket',
|
|
'--bucket',
|
|
help='Google Storage bucket to upload to.')
|
|
help='Google Storage bucket to upload to.')
|
|
|
|
+ parser.add_option('-p',
|
|
|
|
+ '--prefix',
|
|
|
|
+ help='Prefix that goes before object-name (i.e. in '
|
|
|
|
+ 'between bucket and object name).')
|
|
parser.add_option('-o',
|
|
parser.add_option('-o',
|
|
'--object-name',
|
|
'--object-name',
|
|
help='Optional object name of uploaded tar file. '
|
|
help='Optional object name of uploaded tar file. '
|
|
@@ -233,6 +237,9 @@ def main():
|
|
if not object_name:
|
|
if not object_name:
|
|
object_name = get_sha256sum(file)
|
|
object_name = get_sha256sum(file)
|
|
|
|
|
|
|
|
+ if options.prefix:
|
|
|
|
+ object_name = f'{options.prefix}/{object_name}'
|
|
|
|
+
|
|
# Make sure we can find a working instance of gsutil.
|
|
# Make sure we can find a working instance of gsutil.
|
|
if os.path.exists(GSUTIL_DEFAULT_PATH):
|
|
if os.path.exists(GSUTIL_DEFAULT_PATH):
|
|
gsutil = Gsutil(GSUTIL_DEFAULT_PATH, boto_path=options.boto)
|
|
gsutil = Gsutil(GSUTIL_DEFAULT_PATH, boto_path=options.boto)
|
|
@@ -255,7 +262,9 @@ def main():
|
|
gsutil.check_call('version')
|
|
gsutil.check_call('version')
|
|
return gsutil.call('config')
|
|
return gsutil.call('config')
|
|
|
|
|
|
- base_url = 'gs://%s' % options.bucket
|
|
|
|
|
|
+ assert '/' not in options.bucket, "Slashes not allowed in bucket name"
|
|
|
|
+
|
|
|
|
+ base_url = f'gs://{options.bucket}'
|
|
|
|
|
|
generation = upload_to_google_storage(file, base_url, object_name, gsutil,
|
|
generation = upload_to_google_storage(file, base_url, object_name, gsutil,
|
|
options.force, options.gzip,
|
|
options.force, options.gzip,
|