Launchpad

`openstack object save my_container_name my_file.sql.gz` works fine - it saves my_file.gz to the current directory. However, for efficiency reasons I want to stream the file into a program and not save it locally. As a starting point I've tried to run `openstack object save --file - my_container_name my_file.sql.gz | gunzip` as described by `openstack object save --help`, but it fails with the error message "write() argument must be str, not bytes".

Stack trace from running with `--debug`:

write() argument must be str, not bytes
Traceback (most recent call last):
  File "/vagrant/ .venv/lib/ python3. 6/site- packages/ cliff/app. py", line 400, in run_subcommand
    result = cmd.run( parsed_ args)
  File "/vagrant/ .venv/lib/ python3. 6/site- packages/ osc_lib/ command/ command. py", line 41, in run
    return super(Command, self).run( parsed_ args)
  File "/vagrant/ .venv/lib/ python3. 6/site- packages/ cliff/command. py", line 184, in run
    return_code = self.take_ action( parsed_ args) or 0
  File "/vagrant/ .venv/lib/ python3. 6/site- packages/ openstackclient /object/ v1/object. py", line 226, in take_action
    file= parsed_ args.file,
  File "/vagrant/ .venv/lib/ python3. 6/site- packages/ openstackclient /api/object_ store_v1. py", line 382, in object_save
    sys. stdout. write(chunk)
TypeError: write() argument must be str, not bytes
clean_up SaveObject: write() argument must be str, not bytes
Traceback (most recent call last):
  File "/vagrant/ .venv/lib/ python3. 6/site- packages/ osc_lib/ shell.py" , line 134, in run
    ret_val = super(OpenStack Shell, self).run(argv)
  File "/vagrant/ .venv/lib/ python3. 6/site- packages/ cliff/app. py", line 279, in run
    result = self.run_ subcommand( remainder)
  File "/vagrant/ .venv/lib/ python3. 6/site- packages/ osc_lib/ shell.py" , line 169, in run_subcommand
    ret_value = super(OpenStack Shell, self).run_ subcommand( argv)
  File "/vagrant/ .venv/lib/ python3. 6/site- packages/ cliff/app. py", line 400, in run_subcommand
    result = cmd.run( parsed_ args)
  File "/vagrant/ .venv/lib/ python3. 6/site- packages/ osc_lib/ command/ command. py", line 41, in run
    return super(Command, self).run( parsed_ args)
  File "/vagrant/ .venv/lib/ python3. 6/site- packages/ cliff/command. py", line 184, in run
    return_code = self.take_ action( parsed_ args) or 0
  File "/vagrant/ .venv/lib/ python3. 6/site- packages/ openstackclient /object/ v1/object. py", line 226, in take_action
    file= parsed_ args.file,
  File "/vagrant/ .venv/lib/ python3. 6/site- packages/ openstackclient /api/object_ store_v1. py", line 382, in object_save
    sys. stdout. write(chunk)
TypeError: write() argument must be str, not bytes

Setup:

$ python --version
Python 3.6.5
$ openstack --version
openstack 3.15.0
$ uname --kernel-name --kernel-release --kernel-version --machine --processor --hardware-platform --operating-system
Linux 4.15.0-22-generic #24-Ubuntu SMP Wed May 16 12:15:17 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_ RELEASE= 18.04
DISTRIB_ CODENAME= bionic
DISTRIB_ DESCRIPTION= "Ubuntu 18.04 LTS"

Read the original on bugs.launchpad.net ↗