Minio PUT not working

I’m trying to configure an automation that will record cameras when motion is detected, and then upload the file to Amazon S3. I’m having trouble with the minio.put service. I’m testing from the developer tools service page like this:

service: minio.put
data:
  bucket: *****
  file_path: /share/front_yard_20221129-223757.mp4
  key: /front_yard_20221129-223757.mp4

Nothing happens, and the only message logged is this:

2022-11-29 23:43:04.580 INFO (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Running websocket_api script
2022-11-29 23:43:04.581 INFO (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Executing step call service

Is there a way to get debug level messages from minio? I tried adding homeassistant.components.minio: debug to the logger config but that didn’t work.

After rebooting the system, now I’m seeing a more verbose error in the logs. I can replicate the issue using Minio’s public play server:

minio:
  port: 443
  secure: true
  host: play.min.io
  access_key: Q3AM3UQ867SPQQA43P2F
  secret_key: zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG

It errors like this:

2022-11-30 01:12:32.436 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Unexpected error for call_service at pos 1: ResponseError: code: InvalidTokenId, message: The security token included in the request is invalid, bucket_name: elliott, object_name: None, request_id: 172C51D89007BBBC, host_id: f909a117-31f2-40c5-985d-ad4dd02a1fda, region: us-east-1
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 684, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1744, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1787, in _execute_service
    await self._hass.async_add_executor_job(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/minio/__init__.py", line 143, in put_file
    minio_client.fput_object(bucket, key, file_path)
  File "/usr/local/lib/python3.10/site-packages/minio/api.py", line 698, in fput_object
    return self.put_object(bucket_name, object_name, file_data,
  File "/usr/local/lib/python3.10/site-packages/minio/api.py", line 969, in put_object
    return self._do_put_object(bucket_name, object_name,
  File "/usr/local/lib/python3.10/site-packages/minio/api.py", line 1682, in _do_put_object
    response = self._url_open(
  File "/usr/local/lib/python3.10/site-packages/minio/api.py", line 1984, in _url_open
    region = self._get_bucket_region(bucket_name)
  File "/usr/local/lib/python3.10/site-packages/minio/api.py", line 1919, in _get_bucket_region
    region = self._get_bucket_location(bucket_name)
  File "/usr/local/lib/python3.10/site-packages/minio/api.py", line 1957, in _get_bucket_location
    raise ResponseError(response, method, bucket_name).get_exception()

I tried debugging this by running this code manually from within the HA Docker container, but it works fine this way. Not sure what’s different here.

from minio import Minio
client = Minio('play.min.io', 'Q3AM3UQ867SPQQA43P2F', 'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG')
client.fput_object('elliott', 'front_yard_20221129-224534.mp4', '/share/front_yard_20221129-224534.mp4')

From what I can tell the error seems to be because the upload is setting an incorrect x-amz-security-token value - not sure why would homeassistant do this in their code.