From 438e37ce64018a06756d7321a92ab742df4d5857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vykintas=20Baltru=C5=A1aitis?= Date: Thu, 26 Oct 2023 11:46:29 +0300 Subject: [PATCH] Add expire, content_* args --- CHANGELOG.md | 1 + b2/console_tool.py | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a5c6c301..c3154ca28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +* Add `--expires`, `--content-disposition`, `--content-encoding`, `--content-language` options to subcommands `upload-file`, `upload-unbound-stream`, `copy-file-by-id` ### Fixed * `--quiet` now will implicitly set `--noProgress` option as well diff --git a/b2/console_tool.py b/b2/console_tool.py index 2c31de244..0a1dc9c5b 100644 --- a/b2/console_tool.py +++ b/b2/console_tool.py @@ -1020,6 +1020,21 @@ def _setup_parser(cls, parser): parser.add_argument('--metadataDirective', default=None, help=argparse.SUPPRESS) parser.add_argument('--contentType') parser.add_argument('--range', type=parse_range) + parser.add_argument( + '--cache-control', help='Add Cache-Control header' # TODO(vbaltrusaitis-reef): better description + ) + parser.add_argument( + '--content-disposition', help='Add Content-Disposition header' # TODO(vbaltrusaitis-reef): better description + ) + parser.add_argument( + '--content-language', help='Add Content-Language header' # TODO(vbaltrusaitis-reef): better description + ) + parser.add_argument( + '--content-encoding', help='Add Content-Encoding header' # TODO(vbaltrusaitis-reef): better description + ) + parser.add_argument( + '--expires', help='Add Expires header' # TODO(vbaltrusaitis-reef): better description + ) info_group = parser.add_mutually_exclusive_group() @@ -1078,6 +1093,11 @@ def run(self, args): file_retention=file_retention, source_file_info=source_file_info, source_content_type=source_content_type, + cache_control=args.cache_control, + expires=args.expires, + content_disposition=args.content_disposition, + content_encoding=args.content_encoding, + content_language=args.content_language, ) self._print_json(file_version) return 0 @@ -2791,6 +2811,18 @@ def _setup_parser(cls, parser): '--sha1', help="SHA-1 of the data being uploaded for verifying file integrity" ) parser.add_argument('--cache-control', default=None) + parser.add_argument( + '--content-disposition', help='Add Content-Disposition header' # TODO(vbaltrusaitis-reef): better description + ) + parser.add_argument( + '--content-language', help='Add Content-Language header' # TODO(vbaltrusaitis-reef): better description + ) + parser.add_argument( + '--content-encoding', help='Add Content-Encoding header' # TODO(vbaltrusaitis-reef): better description + ) + parser.add_argument( + '--expires', help='Add Expires header' # TODO(vbaltrusaitis-reef): better description + ) parser.add_argument( '--info', action='append', @@ -2842,12 +2874,20 @@ def get_execute_kwargs(self, args) -> dict: self.api.get_bucket_by_name(args.bucketName), "cache_control": args.cache_control, + "content_disposition": + args.content_disposition, + "content_encoding": + args.content_encoding, + "content_language": + args.content_language, "content_type": args.contentType, "custom_upload_timestamp": args.custom_upload_timestamp, "encryption": self._get_destination_sse_setting(args), + "expires": + args.expires, "file_info": file_infos, "file_name":