⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
fix: s3 integration + custom s3 (minio) support
Tomáš Hruška836dc10c2b7d
diff --git a/.env.sample b/.env.sampleindex ee04f7df..2ca5830f 100644--- a/.env.sample+++ b/.env.sample@@ -14,7 +14,9 @@ RE_ARCHIVE_LIMIT=SPACES_KEY=SPACES_SECRET=SPACES_ENDPOINT=+SPACES_BUCKET_NAME=SPACES_REGION=+SPACES_FORCE_PATH_STYLE=# SMTP SettingsNEXT_PUBLIC_EMAIL_PROVIDER=diff --git a/lib/api/storage/createFile.ts b/lib/api/storage/createFile.tsindex 8f55b451..31554fba 100644--- a/lib/api/storage/createFile.ts+++ b/lib/api/storage/createFile.ts@@ -14,7 +14,7 @@ export default async function createFile({}) {if (s3Client) {const bucketParams: PutObjectCommandInput = {- Bucket: process.env.BUCKET_NAME,+ Bucket: process.env.SPACES_BUCKET_NAME,Key: filePath,Body: isBase64 ? Buffer.from(data as string, "base64") : data,};diff --git a/lib/api/storage/moveFile.ts b/lib/api/storage/moveFile.tsindex bbd88874..c86728fd 100644--- a/lib/api/storage/moveFile.ts+++ b/lib/api/storage/moveFile.ts@@ -5,7 +5,7 @@ import removeFile from "./removeFile";export default async function moveFile(from: string, to: string) {if (s3Client) {- const Bucket = process.env.BUCKET_NAME;+ const Bucket = process.env.SPACES_BUCKET_NAME;const copyParams = {Bucket: Bucket,diff --git a/lib/api/storage/readFile.ts b/lib/api/storage/readFile.tsindex 01e6fdab..64ff8d7a 100644--- a/lib/api/storage/readFile.ts+++ b/lib/api/storage/readFile.ts@@ -20,7 +20,7 @@ export default async function readFile(filePath: string) {if (s3Client) {const bucketParams: GetObjectCommandInput = {- Bucket: process.env.BUCKET_NAME,+ Bucket: process.env.SPACES_BUCKET_NAME,Key: filePath,};diff --git a/lib/api/storage/removeFile.ts b/lib/api/storage/removeFile.tsindex 491e24c7..e332829c 100644--- a/lib/api/storage/removeFile.ts+++ b/lib/api/storage/removeFile.ts@@ -6,7 +6,7 @@ import { PutObjectCommandInput, DeleteObjectCommand } from "@aws-sdk/client-s3";export default async function removeFile({ filePath }: { filePath: string }) {if (s3Client) {const bucketParams: PutObjectCommandInput = {- Bucket: process.env.BUCKET_NAME,+ Bucket: process.env.SPACES_BUCKET_NAME,Key: filePath,};diff --git a/lib/api/storage/removeFolder.ts b/lib/api/storage/removeFolder.tsindex 7383b884..e9f7d3b3 100644--- a/lib/api/storage/removeFolder.ts+++ b/lib/api/storage/removeFolder.ts@@ -40,7 +40,7 @@ async function emptyS3Directory(bucket: string, dir: string) {export default async function removeFolder({ filePath }: { filePath: string }) {if (s3Client) {try {- await emptyS3Directory(process.env.BUCKET_NAME as string, filePath);+ await emptyS3Directory(process.env.SPACES_BUCKET_NAME as string, filePath);} catch (err) {console.log("Error", err);}diff --git a/lib/api/storage/s3Client.ts b/lib/api/storage/s3Client.tsindex 8b0ccd55..cebba5ae 100644--- a/lib/api/storage/s3Client.ts+++ b/lib/api/storage/s3Client.ts@@ -6,7 +6,7 @@ const s3Client: S3 | undefined =process.env.SPACES_KEY &&process.env.SPACES_SECRET? new S3({- forcePathStyle: false,+ forcePathStyle: !!process.env.SPACES_FORCE_PATH_STYLE,endpoint: process.env.SPACES_ENDPOINT,region: process.env.SPACES_REGION,credentials: {diff --git a/types/enviornment.d.ts b/types/enviornment.d.tsindex 24c1c442..d2bdbb8a 100644--- a/types/enviornment.d.ts+++ b/types/enviornment.d.ts@@ -13,8 +13,9 @@ declare global {SPACES_KEY?: string;SPACES_SECRET?: string;SPACES_ENDPOINT?: string;- BUCKET_NAME?: string;+ SPACES_BUCKET_NAME?: string;SPACES_REGION?: string;+ SPACES_FORCE_PATH_STYLE?: string;NEXT_PUBLIC_KEYCLOAK_ENABLED?: string;KEYCLOAK_ISSUER?: string;