bookwyrm
bookwyrm copied to clipboard
S3 toolkit
Is your feature request related to a problem? Please describe. As I mentioned in #3201, it looks like currently Bookwyrm has no functionality to validate or set up S3 storage.
It's be great to have it and be able to use it while setting up an instance from scratch or moving to external storage.
Describe the solution you'd like
Currently we have bw-dev copy_media_to_s3
command. Which is good.
I'd also suggest to add a couple of commands like:
-
bw-dev validate_s3_settings
orbw-dev validate_external_storage_settings
(if the project is aiming to support another types of external storages) - this command should make necessary checks and report to user:- Are provided credentials correct
- Does Bookwyrm have all necessary permissions on the bucket with these credentials
- Maybe try to create/delete/etc test file
-
bw-dev set_s3_cors
- this command should just automate the same process which is described in this documentation in the "CORS settings". The only thing most users are needed to customize is just a domain. And we have it in the.env
file. This command can also ask user if they want to also usewww.
prefix to not add unnecessary rules if they're not needed.
How I imagine validate_s3_settings
for example:
# ./bw-dev validate_s3_settings
Checking S3 credentials ..................... [valid]
Checking bucket permissions .......... [not set]
Error: Bookwyrm has no write permissions on the bucket
Error: Bookwyrm has no read permissions on the bucket
Error: Bookwyrm has no delete permissions on the bucket
Error: Bookwyrm can't set CORS for the bucket
<...>
Checking file operations .................... [skipped]
It also could be great if S3-related features like copy_media_to_s3
was using the same check as "Credentials check" before executing anything to avoid unexpected problems in the runtime.