You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
But the images are still also stored locally on disk at /var/lib/matrix-synapse/media and if i remove the folder /var/lib/matrix-synapse/media the images are not shown anymore although they are still in the s3 bucket. So it seems to me that the s3_storage_provider.S3StorageProviderBackend does nothing but also store the data as a backup option?
I also could not find any documentation about media_storage_providers in this repo.
Can someone explain what they are and how they are supposed to work please.
My use case is that i want only to use the S3 Bucket and no local storage. Is this possible with media_storage_providers?
I'm also interested in what the media storage is for.
For me too, the file is stored locally in the file system AND on the S3.
The strange thing is that store_local: False means that the file is only saved in the file system and NOT on the S3!
But if I delete the local directory, all files are still available to me.
# Media storage providers allow media to be stored in different
# locations.
#
#media_storage_providers:
# - module: file_system
# # Whether to write new local files.
# store_local: false
# # Whether to write new remote media
# store_remote: false
# # Whether to block upload requests waiting for write to this
# # provider to complete
# store_synchronous: false
# config:
# directory: /mnt/some/other/directory
Looking at some of the code it seems that the "local" vs. "remote" in those configurations is whether the media was uploaded directly to this server vs. whether it was received over federation (it does not mean whether the data is stored "locally" on the server vs. "remote on S3", which is how I originally read it). See
"store_local", # Whether to store newly uploaded local files
"store_remote", # Whether to store newly downloaded remote files
"store_synchronous", # Whether to wait for successful storage for local uploads
What's your configuration for backup_media_store_path? It looks like the file system store might be enabled if backup_media_store_path is set to true, see
Okay, I think I understand how the media storage providers are meant.
The bad news: It is not possible to replace the local storage (media_store_path) with the remote storage.
The storage of the media is primarily managed by the MediaStorage and not the StorageProvider.
However, it should not be a problem to simply delete the local files from media_store_path at regular intervals. In this case, the file is then delivered by the first StorageProvider who still holds the file.
Note there is an alternative solution which in theory should be easy to config so that the only media directory is an S3 bucket. I'm going to try it myself when I set my server up within the next few days.
You install and configure Goofys, make sure it mounts an S3 bucket directory on boot, and then you can simply change the media directory in the Matrix config to that one and turn off the S3 storage provider.
As far as Matrix is concerned it is writing media to the local filesystem but it'll be transparently using your S3 bucket instead.
This is the S3 config from the popular Ansible Docker deploy.
Reacted by Bailey Stoner, Nicholas Steicke, Joel Wejdenstål, 4censord, Guillaume Ausset and Kang Jaehong
Note there is an alternative solution which in theory should be easy to config so that the only media directory is an S3 bucket. I'm going to try it myself when I set my server up within the next few days.
You install and configure Goofys, make sure it mounts an S3 bucket directory on boot, and then you can simply change the media directory in the Matrix config to that one and turn off the S3 storage provider.
As far as Matrix is concerned it is writing media to the local filesystem but it'll be transparently using your S3 bucket instead.
This is the S3 config from the popular Ansible Docker deploy.
Any luck with this? I am looking for the same solution on how to replace local media storage with S3.
I bet using goofys works worse and is more brittle than just using the s3 storage provider. The local storage even has the advantage of being a cache for recently uploaded files.
Why not just run the clean-up script regularly? (Or run synapse in ephemeral containers, which, at least for me, is already sufficient?)
I bet using goofys works worse and is more brittle than just using the s3 storage provider. The local storage even has the advantage of being a cache for recently uploaded files.
Why not just run the clean-up script regularly? (Or run synapse in ephemeral containers, which, at least for me, is already sufficient?)
Couple of reasons:
I want everything to go into S3 for speed and reliability reasons
Activity
tristanlins commentedon Apr 12, 2020
I'm also interested in what the media storage is for.
For me too, the file is stored locally in the file system AND on the S3.
The strange thing is that
store_local: Falsemeans that the file is only saved in the file system and NOT on the S3!But if I delete the local directory, all files are still available to me.
I use a Minio server as S3 storage.
tristanlins commentedon Apr 12, 2020
What I just noticed is that all pre-generated thumbnails are ONLY stored on the S3 as expected. 🤔
clokep commentedon Apr 13, 2020
The documentation is pretty light, but seems to be at https://github.com/matrix-org/synapse/blob/develop/docs/media_repository.md, the default config could certainly offer a bit more info:
synapse/docs/sample_config.yaml
Lines 695 to 708 in 883ac4b
Looking at some of the code it seems that the "local" vs. "remote" in those configurations is whether the media was uploaded directly to this server vs. whether it was received over federation (it does not mean whether the data is stored "locally" on the server vs. "remote on S3", which is how I originally read it). See
synapse/synapse/config/repository.py
Lines 46 to 48 in 9dfcf47
What's your configuration for
backup_media_store_path? It looks like the file system store might be enabled ifbackup_media_store_pathis set to true, seesynapse/synapse/config/repository.py
Lines 118 to 126 in 883ac4b
tristanlins commentedon Apr 14, 2020
I have not specified
backup_media_store_path, I will take a deeper look into this...tristanlins commentedon Apr 14, 2020
The
backup_media_store_pathis not the problem, it cannot be used together withmedia_storage_providers:synapse/synapse/config/repository.py
Lines 112 to 117 in 883ac4b
tristanlins commentedon Apr 14, 2020
Okay, I think I understand how the media storage providers are meant.
The bad news: It is not possible to replace the local storage (
media_store_path) with the remote storage.The storage of the media is primarily managed by the MediaStorage and not the StorageProvider.
synapse/synapse/rest/media/v1/media_repository.py
Line 160 in 9dfcf47
synapse/synapse/rest/media/v1/media_repository.py
Line 492 in 9dfcf47
synapse/synapse/rest/media/v1/media_repository.py
Line 539 in 9dfcf47
synapse/synapse/rest/media/v1/media_repository.py
Line 648 in 9dfcf47
This in turn always saves the file first in the local directory:
synapse/synapse/rest/media/v1/media_storage.py
Lines 65 to 70 in 9dfcf47
And then this locally stored file is passed on to the StorageProviders:
synapse/synapse/rest/media/v1/media_storage.py
Lines 109 to 112 in 9dfcf47
I'm slowly beginning to understand what the s3_media_upload.py cleanup job is all about.
https://github.com/matrix-org/synapse-s3-storage-provider#regular-cleanup-job
However, it should not be a problem to simply delete the local files from
media_store_pathat regular intervals. In this case, the file is then delivered by the first StorageProvider who still holds the file.synapse/synapse/rest/media/v1/media_storage.py
Lines 143 to 151 in 9dfcf47
I hope I have analyzed it correctly.
Perhaps a responsible developer can comment again on whether this is correct ?!
babolivier commentedon Apr 22, 2020
Hey @tristanlins, yes this seems correct to me.
nemani commentedon Jul 16, 2020
Can we add a link to this issue at the relevant place in the sample config file?
Thanks!
ftpmorph commentedon Feb 3, 2021
Note there is an alternative solution which in theory should be easy to config so that the only media directory is an S3 bucket. I'm going to try it myself when I set my server up within the next few days.
You install and configure Goofys, make sure it mounts an S3 bucket directory on boot, and then you can simply change the media directory in the Matrix config to that one and turn off the S3 storage provider.
As far as Matrix is concerned it is writing media to the local filesystem but it'll be transparently using your S3 bucket instead.
This is the S3 config from the popular Ansible Docker deploy.
sorcer1122 commentedon Jan 8, 2023
Any luck with this? I am looking for the same solution on how to replace local media storage with S3.
djmaze commentedon Jan 8, 2023
I bet using goofys works worse and is more brittle than just using the s3 storage provider. The local storage even has the advantage of being a cache for recently uploaded files.
Why not just run the clean-up script regularly? (Or run synapse in ephemeral containers, which, at least for me, is already sufficient?)
sorcer1122 commentedon Jan 8, 2023
Couple of reasons: