Something wrong with S3 Compatible Services while uploading #1789

Closed
opened 2026-02-05 01:52:56 +03:00 by OVERLORD · 8 comments
Owner

Originally created by @Creling on GitHub (Jul 11, 2020).

Hello:
I'm now working with BookStack v0.29.3.
I configure the S3 Compatible Services like the image below and the server provider is backblaze.

STORAGE_TYPE=s3
STORAGE_S3_KEY="002ed5b38xxxxxx"
STORAGE_S3_SECRET="K002xxxxx"
STORAGE_S3_BUCKET="<bucket-name>"
STORAGE_S3_ENDPOINT="https://s3.us-west-002.backblazeb2.com"
STORAGE_URL="https://s3.us-west-002.backblazeb2.com/<bucket-name>"

However, when I try to upload images from clipboard, an error occurred:

image
image

PS: The permissions are ok.

Originally created by @Creling on GitHub (Jul 11, 2020). Hello: I'm now working with **BookStack v0.29.3**. I configure the S3 Compatible Services like the image below and the server provider is backblaze. ``` STORAGE_TYPE=s3 STORAGE_S3_KEY="002ed5b38xxxxxx" STORAGE_S3_SECRET="K002xxxxx" STORAGE_S3_BUCKET="<bucket-name>" STORAGE_S3_ENDPOINT="https://s3.us-west-002.backblazeb2.com" STORAGE_URL="https://s3.us-west-002.backblazeb2.com/<bucket-name>" ``` However, when I try to upload images from clipboard, an error occurred: ![image](https://user-images.githubusercontent.com/43109504/87224730-393f3b00-c3ba-11ea-9fa2-c58ec1dbcb3c.png) ![image](https://user-images.githubusercontent.com/43109504/87224742-48be8400-c3ba-11ea-9b89-9a0a36e31991.png) PS: The permissions are ok.
Author
Owner

@fabiodcorreia commented on GitHub (Aug 26, 2020):

I have this working for that same version, I had that problem but it was because the app key was wrong and needs to be the applicationKey.

@fabiodcorreia commented on GitHub (Aug 26, 2020): I have this working for that same version, I had that problem but it was because the app key was wrong and needs to be the applicationKey.
Author
Owner

@ssddanbrown commented on GitHub (Dec 11, 2020):

So I've just given this a test.

This can occur when attempting to upload an image within a public bucket. By default BookStack will upload files as private then mark them as public. Unfortunately backblaze will reject a request to upload a private file within a public bucket.

We could work around that quite simply, but it does mean that backblaze can't really be used as the only storage mechanism for BookStack without at least exposing attachment files, until it's able to support both private and public files within a single bucket.

We could technically add support for multiple buckets so you could have one for attachments and one for images but I don't think that'd be worth the effort, support and maintenance just for backblaze. Shame as I really like b2 storage.

@ssddanbrown commented on GitHub (Dec 11, 2020): So I've just given this a test. This can occur when attempting to upload an image within a public bucket. By default BookStack will upload files as private then mark them as public. Unfortunately backblaze will reject a request to upload a private file within a public bucket. We could work around that quite simply, but it does mean that backblaze can't really be used as the only storage mechanism for BookStack without at least exposing attachment files, until it's able to support both private and public files within a single bucket. We could technically add support for multiple buckets so you could have one for attachments and one for images but I don't think that'd be worth the effort, support and maintenance just for backblaze. Shame as I really like b2 storage.
Author
Owner

@ssddanbrown commented on GitHub (Mar 9, 2021):

Closing this off as multiple potential solutions have been provided and there has been no further discussion.

@ssddanbrown commented on GitHub (Mar 9, 2021): Closing this off as multiple potential solutions have been provided and there has been no further discussion.
Author
Owner

@Akarys42 commented on GitHub (Nov 27, 2022):

@ssddanbrown I am still experiencing this issue, which means I cannot deploy BookStack to our infrastructure and had to roll back, due to our CDN being backed by Backblaze.

We could work around that quite simply, but it does mean that backblaze can't really be used as the only storage mechanism for BookStack without at least exposing attachment files, until it's able to support both private and public files within a single bucket.

That seems like an acceptable trade-off to me. The files shouldn't be uploaded as private and then switched to public. Would it be possible to re-open the issue and implement this?

@Akarys42 commented on GitHub (Nov 27, 2022): @ssddanbrown I am still experiencing this issue, which means I cannot deploy BookStack to our infrastructure and had to roll back, due to our CDN being backed by Backblaze. > We could work around that quite simply, but it does mean that backblaze can't really be used as the only storage mechanism for BookStack without at least exposing attachment files, until it's able to support both private and public files within a single bucket. That seems like an acceptable trade-off to me. The files shouldn't be uploaded as private and then switched to public. Would it be possible to re-open the issue and implement this?
Author
Owner

@ssddanbrown commented on GitHub (Nov 27, 2022):

@Akarys42 Are you sure the issue is the same? Although the error message may appear the same, it does not indicate the same underlying issue. Permission handling for s3-like usages has since changed to avoid permission setting actions.

@ssddanbrown commented on GitHub (Nov 27, 2022): @Akarys42 Are you sure the issue is the same? Although the error message may appear the same, it does not indicate the same underlying issue. Permission handling for s3-like usages has since changed to avoid permission setting actions.
Author
Owner

@Akarys42 commented on GitHub (Nov 27, 2022):

@ssddanbrown yes, the error happens when trying to upload a new avatar for example. The file is uploaded with the private canned ACL which gets rejected by Backblaze since the bucket is public.

@Akarys42 commented on GitHub (Nov 27, 2022): @ssddanbrown yes, the error happens when trying to upload a new avatar for example. The file is uploaded with the `private` canned ACL which gets rejected by Backblaze since the bucket is public.
Author
Owner

@ssddanbrown commented on GitHub (Nov 27, 2022):

@Akarys42 Ah, I see.

To be honest I'm not eager on complicating things with additional options/logic, even if relatively minor, to solve a relatively limited case suited to appease the logic of a single external provider. Especially so with options that could result in over exposure of stored files without careful considerations or extra checks within the system.

It might be possible to work around this via a config tweak using the logical theme system to alter the storage config defaults. I've not tested this connected to an s3 system, but the following functions.php may work for this:

<?php

use BookStack\Facades\Theme;
use BookStack\Theming\ThemeEvents;

Theme::listen(ThemeEvents::APP_BOOT, function() {
    config()->set('filesystems.disks.s3.visibility', 'public');
});
@ssddanbrown commented on GitHub (Nov 27, 2022): @Akarys42 Ah, I see. To be honest I'm not eager on complicating things with additional options/logic, even if relatively minor, to solve a relatively limited case suited to appease the logic of a single external provider. Especially so with options that could result in over exposure of stored files without careful considerations or extra checks within the system. It might be possible to work around this via a config tweak using the [logical theme system](https://github.com/BookStackApp/BookStack/blob/development/dev/docs/logical-theme-system.md) to alter the storage config defaults. I've not tested this connected to an s3 system, but the following `functions.php` may work for this: ```php <?php use BookStack\Facades\Theme; use BookStack\Theming\ThemeEvents; Theme::listen(ThemeEvents::APP_BOOT, function() { config()->set('filesystems.disks.s3.visibility', 'public'); }); ```
Author
Owner

@Akarys42 commented on GitHub (Nov 27, 2022):

Alright, even if I'm not a fan of that solution, that works. Thanks for your help.

@Akarys42 commented on GitHub (Nov 27, 2022): Alright, even if I'm not a fan of that solution, that works. Thanks for your help.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#1789