Skip to content
Init is here / May 19 - 23
Back

S3 Bucket Error

  • 0
  • Self Hosted
Starley
21 May, 2025, 18:09

Good afternoon. I tried to configure _APP_STORAGE_S3_ENDPOINT, Appwrite version 1.7.0. I tried two different providers, but on both I encountered an access error or a lack of Bucket. All accesses and stuff have been checked manually, there are no problems. Apparently, when using _APP_STORAGE_S3_ENDPOINT, Appwrite does not handle _APP_STORAGE_S3_BUCKET correctly.

The screenshots are my tests of two S3-compatible providers.

The settings of the first one are _APP_STORAGE_S3_ENDPOINT=storage.yandexcloud.net

{"message":"Storage bucket with the requested ID could not be found.","code":404,"type":"storage_bucket_not_found","version":"1.7.0"}

Settings of the second one: _APP_STORAGE_S3_ENDPOINT=s3.twcstorage.ru

{"message":"Storage bucket with the requested ID could not be found.","code":404,"type":"storage_bucket_not_found","version":"1.7.0"}

I tried to make changes to the project code. If you change the file app/init.php from 1523 to 1572, the line is as follows, then everything works without problems.

TypeScript
    if (!empty($connection)) {
        $acl = 'private';
        $device = Storage::DEVICE_LOCAL;
        $accessKey = '';
        $accessSecret = '';
        $bucket = '';
        $region = '';
        $endPoint = 's3.twcstorage.ru';

        try {
            $dsn = new DSN($connection);
            $device = $dsn->getScheme();
            $accessKey = $dsn->getUser() ?? '';
            $accessSecret = $dsn->getPassword() ?? '';
            $bucket = $dsn->getPath() ?? '';
            $region = $dsn->getParam('region');
        } catch (\Throwable $e) {
            Console::warning($e->getMessage() . 'Invalid DSN. Defaulting to Local device.');
        }

        switch ($device) {
            case Storage::DEVICE_S3:
                return new S3($root, $accessKey, $accessSecret, $bucket, $region, $acl, 's3.twcstorage.ru');
            case STORAGE::DEVICE_DO_SPACES:
                $device = new DOSpaces($root, $accessKey, $accessSecret, $bucket, $region, $acl);
                $device->setHttpVersion(S3::HTTP_VERSION_1_1);
                return $device;
            case Storage::DEVICE_BACKBLAZE:
                return new Backblaze($root, $accessKey, $accessSecret, $bucket, $region, $acl);
            case Storage::DEVICE_LINODE:
                return new Linode($root, $accessKey, $accessSecret, $bucket, $region, $acl);
            case Storage::DEVICE_WASABI:
                return new Wasabi($root, $accessKey, $accessSecret, $bucket, $region, $acl);
            case Storage::DEVICE_LOCAL:
            default:
                return new Local($root);
        }
    } else {
        switch (strtolower(System::getEnv('_APP_STORAGE_DEVICE', Storage::DEVICE_LOCAL) ?? '')) {
            case Storage::DEVICE_LOCAL:
            default:
                return new Local($root);
            case Storage::DEVICE_S3:
                $s3AccessKey = System::getEnv('_APP_STORAGE_S3_ACCESS_KEY', '');
                $s3SecretKey = System::getEnv('_APP_STORAGE_S3_SECRET', '');
                $s3Region = System::getEnv('_APP_STORAGE_S3_REGION', '');
                $s3Bucket = System::getEnv('_APP_STORAGE_S3_BUCKET', '');
                $s3EndPoint = 's3.twcstorage.ru';
                $s3Acl = 'private';
                return new S3($root, $s3AccessKey, $s3SecretKey, $s3Bucket, $s3Region, $s3Acl, $s3EndPoint);```
TL;DR
Developers encountered issues setting up S3 buckets with Appwrite version 1.7.0. The code had to be adjusted in app/init.php for proper function but only works when changes are made from line 1523 to 1572. Refer to the specific code snippet provided for the detailed changes required to resolve the issue.
Starley
21 May, 2025, 18:09

S3 Bucket Error

ideclon
21 May, 2025, 18:12

Was this previously working on 1.6.2?

Starley
21 May, 2025, 18:14

In version 1.6.2, _APP_STORAGE_S3_ENDPOINT did not work, the documentation also states that you should use >1.7 The code that I have attached works in 1.6.2

ideclon
21 May, 2025, 18:17

Oh, whoops - sorry

ideclon
21 May, 2025, 18:18

FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting).

Starley
21 May, 2025, 18:20

Thanks, I've updated the code)

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more