Media browser permission denied

Hi all,

I am attempting to add the ‘media_browser’ to my home assistant instance (HA Core 2022.4.3) and am running into a few issues.

I have successfully added to my configuration.yaml the following:

media_source:

homeassistant:
  media_dirs:
    local: /media

This is a valid configuration (so best I can tell!) as per https://www.home-assistant.io/integrations/media_source/. The Media Browser appears as expected in the sidebar. I have also created a ‘media’ folder in the same location as my configuration.yaml file.

Now for the problem. If I place any media inside the media folder, it does not appear in HA. And any attempts to upload through the web ui results in the following error:

error1

2022-06-01 08:01:06 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/share/homeassistant/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/share/homeassistant/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/share/homeassistant/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/local/share/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/local/share/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/forwarded.py", line 222, in forwarded_middleware
    return await handler(request)
  File "/usr/local/share/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/local/share/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/ban.py", line 79, in ban_middleware
    return await handler(request)
  File "/usr/local/share/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/auth.py", line 219, in auth_middleware
    return await handler(request)
  File "/usr/local/share/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/view.py", line 137, in handle
    result = await result
  File "/usr/local/share/homeassistant/lib/python3.9/site-packages/homeassistant/components/media_source/local_source.py", line 290, in post
    await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/share/homeassistant/lib/python3.9/site-packages/homeassistant/components/media_source/local_source.py", line 315, in _move_file
    with target_path.open("wb") as target_fp:
  File "/usr/local/lib/python3.9/pathlib.py", line 1252, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/usr/local/lib/python3.9/pathlib.py", line 1120, in _opener
    return self._accessor.open(self, flags, mode)
PermissionError: [Errno 13] Permission denied: '/media/silence.mp3'

It is showing in the logs above as a permission error, yet I have given both the mp3 file and the media folder fully open permissions (chmod 777). There are no symlinks or anything fancy.

Any ideas what might be going on?

Thank you :grinning_face_with_smiling_eyes:

I finally solved this. Turns out I had to point to the full path, not to just the path of the folder relative to the configuration.yaml file (as the documentation would have you believe :unamused:)

In my case, the following adjustment worked:

media_source:

homeassistant:
  media_dirs:
    local: /home/homeassistant/homeassistant/media