-
Notifications
You must be signed in to change notification settings - Fork 4.4k
enabling file permissions #4661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
via cache preview
via storage::preview
$bucketId = $parts[1] ?? null; | ||
|
||
$bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); | ||
|
||
if ($bucket->isEmpty() || (!$bucket->getAttribute('enabled') && $mode !== APP_MODE_ADMIN)) { | ||
throw new Exception(Exception::STORAGE_BUCKET_NOT_FOUND); | ||
} | ||
|
||
$fileSecurity = $bucket->getAttribute('fileSecurity', false); | ||
$validator = new Authorization(Database::PERMISSION_READ); | ||
$valid = $validator->isValid($bucket->getRead()); | ||
if (!$fileSecurity && !$valid) { | ||
throw new Exception(Exception::USER_UNAUTHORIZED); | ||
} | ||
|
||
$parts = explode('/', $data['resource']); | ||
$fileId = $parts[1] ?? null; | ||
|
||
if ($fileSecurity && !$valid) { | ||
$file = $dbForProject->getDocument('bucket_' . $bucket->getInternalId(), $fileId); | ||
} else { | ||
$file = Authorization::skip(fn() => $dbForProject->getDocument('bucket_' . $bucket->getInternalId(), $fileId)); | ||
} | ||
|
||
if ($file->isEmpty()) { | ||
throw new Exception(Exception::STORAGE_FILE_NOT_FOUND); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested and confirm this does work. It's just unfortunate there's a lot of duplicate code between here and the storage API.
@shimonewman we need to remove caching from the avatars API we talked about |
Done |
No, all good here.
[Setup] - Server database init started...
[Setup] - Creating database: appwrite...
[Setup] - Creating collection: databases...
[Setup] - Creating collection: attributes...
[Setup] - Creating collection: indexes...
[Setup] - Creating collection: projects...
[Setup] - Creating collection: platforms...
[Setup] - Creating collection: domains...
[Setup] - Creating collection: keys...
[Setup] - Creating collection: webhooks...
[Setup] - Creating collection: users...
[Setup] - Creating collection: tokens...
[Setup] - Creating collection: sessions...
[Setup] - Creating collection: teams...
[Setup] - Creating collection: memberships...
[Setup] - Creating collection: functions...
[Setup] - Creating collection: deployments...
[Setup] - Creating collection: builds...
[Setup] - Creating collection: executions...
[Setup] - Creating collection: certificates...
[Setup] - Creating collection: buckets...
[Setup] - Creating collection: stats...
[Setup] - Creating collection: realtime...
[Setup] - Creating collection: cache...
[Setup] - Creating collection: variables...
[Setup] - Creating default bucket...
[Setup] - Creating files collection for default bucket...
[Setup] - Server database init completed...
Server started successfully (max payload is 6,291,456 bytes)
…On Tue, Nov 15, 2022 at 3:13 AM Steven ***@***.***> wrote:
@shimonewman <https://github.com/shimonewman>, I can't get appwrite to
run on this branch. appwrite container fails with:
appwrite | [Setup] - Creating database: appwrite...
appwrite |
appwrite | Fatal error: Uncaught ArgumentCountError: Too few arguments to function Utopia\Database\Database::create(), 0 passed in /usr/src/code/app/http.php on line 96 and exactly 1 expected in /usr/src/code/vendor/utopia-php/database/src/Database/Database.php:335
appwrite | Stack trace:
appwrite | #0 /usr/src/code/app/http.php(96): Utopia\Database\Database->create()
appwrite | #1 {main}
appwrite | thrown in /usr/src/code/vendor/utopia-php/database/src/Database/Database.php on line 335
appwrite | [2022-11-15 01:06:02 #1.5] ERROR php_swoole_server_rshutdown() (ERRNO 503): Fatal error: Uncaught ArgumentCountError: Too few arguments to function Utopia\Database\Database::create(), 0 passed in /usr/src/code/app/http.php on line 96 and exactly 1 expected in /usr/src/code/vendor/utopia-php/database/src/Database/Database.php:335
appwrite | Stack trace:
appwrite | #0 /usr/src/code/app/http.php(96): Utopia\Database\Database->create()
appwrite | #1 {main}
appwrite | thrown in /usr/src/code/vendor/utopia-php/database/src/Database/Database.php on line 335
Does this happen to you?
—
Reply to this email directly, view it on GitHub
<#4661 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFVEPWQGYYZEWBIOK3HI5QTWILPSDANCNFSM6AAAAAAR4MCRHQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Uh oh!
There was an error while loading. Please reload this page.