-
-
Notifications
You must be signed in to change notification settings - Fork 826
feat: Add support for S3 as an asset storage layer #1703
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
Deploying karakeep-landing with
|
Latest commit: |
fa27add
|
Status: | ✅ Deploy successful! |
Preview URL: | https://5e837fad.karakeep-landing.pages.dev |
Branch Preview URL: | https://feat-s3.karakeep-landing.pages.dev |
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.
Pull Request Overview
Adds support for using S3-compatible object storage as an alternative asset backend.
- Introduces a new
AssetStore
interface with both local filesystem and S3 implementations. - Updates configuration schema, dependencies, docs, and Docker Compose to enable MinIO/S3 testing.
- Refactors API utilities and adds end-to-end tests for S3 and filesystem stores.
Reviewed Changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
packages/shared/package.json | Added @aws-sdk/client-s3 dependency |
packages/shared/config.ts | Defined new S3‐related environment variables |
packages/shared/assetdb.ts | Refactored asset logic into AssetStore interface with LocalFileSystemAssetStore and S3AssetStore |
packages/api/utils/upload.ts | Broadened stream type to NodeJS.ReadableStream |
packages/api/utils/assets.ts | Added await to createAssetReadStream calls |
packages/e2e_tests/docker-compose.yml | Added MinIO service for S3 testing |
docs/docs/03-configuration.md | Documented new S3 storage environment variables |
packages/e2e_tests/package.json | Added S3 SDK dependency and no-build test flag |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (6)
packages/shared/assetdb.ts:113
- Missing import for
crypto
. Addimport crypto from "crypto";
at the top to avoid runtime errors.
return crypto.randomUUID();
packages/shared/assetdb.ts:545
serverConfig
is not imported in this file, causing a reference error. Import it fromconfig.ts
(e.g.,import { serverConfig } from "./config";
).
const config = serverConfig.assetStore;
packages/shared/config.ts:89
- Typo in comment: use "separate" instead of "separete".
// A flag to detect if the user is running in the old separete containers setup
packages/shared/assetdb.ts:270
- The leading slash in the glob pattern may prevent matching relative paths under
rootPath
. Use**/**/asset.bin
instead.
const g = new Glob(`/**/**/asset.bin`, {
packages/shared/assetdb.ts:123
- User‐provided
userId
andassetId
should be validated or sanitized to prevent path traversal (e.g., disallow..
segments).
private getAssetDir(userId: string, assetId: string) {
packages/shared/assetdb.ts:472
- Deleting objects one-by-one can be slow for many files. Consider using S3's
DeleteObjectsCommand
to batch up to 1000 keys per request.
const deletePromises = listResponse.Contents.map((obj: _Object) =>
Will there be a one-off command to automatically migrate existing assets to the new S3 folder? |
@maelp I'm not planning to currently implement one, but an AI agent should be able to oneshot a script by just reading the |
I could take a look at that, but not sure if I would be able to run it like this from the install since I’m running with docker-compose so I guess I would need to add some button in the interface On 22 Jul 2025, at 09:01, Mohamed Bassem ***@***.***> wrote:MohamedBassem left a comment (karakeep-app/karakeep#1703)
@maelp I'm not planning to currently implement one, but an AI agent should be able to oneshot a script by just reading the assetDb.ts file.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
gave it a try, worked just fine. Moved the local assets folder, restarted Karakeep and it is fetching all data from s3: for dir in /data/karakeep-data/assets/*/*; do
userId=$(basename "$(dirname "$dir")")
assetId=$(basename "$dir")
ctype=$(jq -r '.contentType' "$dir/metadata.json")
fname=$(jq -r '.fileName // empty' "$dir/metadata.json")
aws s3 cp "$dir/asset.bin" "s3://<bucket-name>/$userId/$assetId" \
--content-type "$ctype" \
$( [ -n "$fname" ] && printf -- '--metadata x-amz-meta-file-name=%s' "$fname" )
done |
@pew Thanks a lot for writing the script, it looks about right to me. I think however, we're also missing |
Fixes #305