Skip to content
Snippets Groups Projects
Verified Commit 3d6c5c7a authored by Adrian Paschkowski's avatar Adrian Paschkowski :thinking:
Browse files

Save minio uploads in subpath

parent 76367d26
No related branches found
No related tags found
No related merge requests found
......@@ -5,5 +5,6 @@ MINIO_ACCESS_KEY=
MINIO_SECRET_KEY=
MINIO_SSL=true
MINIO_BUCKET=
MINIO_ENTRY_IMAGE_PATH=images
TELEGRAM_TOKEN=
DATABASE_URL=
......@@ -26,6 +26,7 @@ sudo docker run \
-e MINIO_SECRET_KEY=<REPLACE> \
-e MINIO_SSL=true \
-e MINIO_BUCKET=lissy \
-e MINIO_ENTRY_IMAGE_PATH=images \
-e TELEGRAM_TOKEN=<REPLACE> \
-e DATABASE_URL=postgresql://lissy:1234@postgres:5432/lissy \
-d ai/lissy-api:latest
......
......@@ -16,11 +16,11 @@ export class MinioService {
});
}
async saveFile(id: string, ext: string, data: Readable | Buffer) {
async saveFile(path: string, data: Readable | Buffer) {
return new Promise<void>((resolve, reject) => {
this.minio.putObject(
process.env.MINIO_BUCKET,
`${id}.${ext}`,
path,
data,
(err) => {
if (err) {
......
......@@ -239,7 +239,10 @@ export class TelegramService implements OnModuleInit {
.then((res) => res.arrayBuffer())
.then((buf) => Buffer.from(buf));
await this.minio.saveFile(image_id, 'jpg', res);
await this.minio.saveFile(
`${process.env.MINIO_ENTRY_IMAGE_PATH}/${image_id}.jpg`,
res,
);
}
await this.prisma.entry.create({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment