Skip to content

Bypass file-type checking if mime-type is provided #49

@krowvin

Description

@krowvin

CLI Script

blob

Describe the bug

Attempting to test the blob upload on a unix system I ran into an error with the mimetype checking. I wanted to override the mimetype manually with the args and it still fails on the check.

Bypass all file type checking if one is specified.

REDACTED relevant log output

user@host:~$ cwms-cli blob upload --office SWT --blob-id=HELLO.TXT --input-file=hello.txt --description="Test File!" --media-type=plain/text
Traceback (most recent call last):
  File "/wm/office/user/.local/bin/cwms-cli", line 8, in <module>
    sys.exit(cli())
  File "/wm/office/user/.local/lib/python3.9/site-packages/click/core.py", line 1161, in __call__
    return self.main(*args, **kwargs)
  File "/wm/office/user/.local/lib/python3.9/site-packages/click/core.py", line 1082, in main
    rv = self.invoke(ctx)
  File "/wm/office/user/.local/lib/python3.9/site-packages/click/core.py", line 1697, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/wm/office/user/.local/lib/python3.9/site-packages/click/core.py", line 1697, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/wm/office/user/.local/lib/python3.9/site-packages/click/core.py", line 1443, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/wm/office/user/.local/lib/python3.9/site-packages/click/core.py", line 788, in invoke
    return __callback(*args, **kwargs)
  File "/wm/office/user/.local/lib/python3.9/site-packages/cwmscli/commands/commands_cwms.py", line 135, in blob_upload
    from cwmscli.commands.blob import upload_cmd
  File "/wm/office/user/.local/lib/python3.9/site-packages/cwmscli/commands/blob.py", line 30, in <module>
    def _determine_ext(data: bytes | str, write_type: str) -> str:
TypeError: unsupported operand type(s) for |: 'type' and 'type'

Steps to Reproduce

pip3 install git+https://github.com/HydrologicEngineeringCenter/cwms-cli.git@main

echo export PATH="$HOME/.local/bin:$PATH" >> ~/.bashrc

source ~/.bashrc

cwms-cli blob upload --help

cwms-cli blob upload --office SWT --blob-id=HELLO.TXT --input-file=hello.txt --description="Test File!" --media-type=plain/text

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions