summaryrefslogtreecommitdiff
path: root/packages/backend/src
diff options
context:
space:
mode:
authorMarie <github@yuugi.dev>2025-03-28 14:36:44 +0100
committerMarie <github@yuugi.dev>2025-03-28 14:36:44 +0100
commit0481b25a62457f9ae44f1ef60e71dbab1944bde1 (patch)
tree33163fa2cf6bc1e400cf49f896852bd164ee8e71 /packages/backend/src
parentApply suggestions (diff)
downloadsharkey-0481b25a62457f9ae44f1ef60e71dbab1944bde1.tar.gz
sharkey-0481b25a62457f9ae44f1ef60e71dbab1944bde1.tar.bz2
sharkey-0481b25a62457f9ae44f1ef60e71dbab1944bde1.zip
upd: create usingBunnyCDN
Diffstat (limited to 'packages/backend/src')
-rw-r--r--packages/backend/src/core/BunnyService.ts7
-rw-r--r--packages/backend/src/core/DriveService.ts4
2 files changed, 8 insertions, 3 deletions
diff --git a/packages/backend/src/core/BunnyService.ts b/packages/backend/src/core/BunnyService.ts
index 1563bc2711..3931ccfdd1 100644
--- a/packages/backend/src/core/BunnyService.ts
+++ b/packages/backend/src/core/BunnyService.ts
@@ -30,6 +30,11 @@ export class BunnyService {
}
@bindThis
+ public usingBunnyCDN(meta: MiMeta) {
+ return meta.objectStorageEndpoint && meta.objectStorageEndpoint.includes('bunnycdn.com') ? true : false;
+ }
+
+ @bindThis
public async upload(meta: MiMeta, path: string, input: fs.ReadStream | Buffer) {
const client = this.getBunnyInfo(meta);
@@ -41,7 +46,7 @@ export class BunnyService {
const data = Buffer.isBuffer(input) ? Readable.from(input) : input;
const agent = this.httpRequestService.getAgentByUrl(new URL(`${client.fullUrl}/${path}`), !meta.objectStorageUseProxy, true);
-
+
// Seperation of path and host/domain is required here
const options = {
method: 'PUT',
diff --git a/packages/backend/src/core/DriveService.ts b/packages/backend/src/core/DriveService.ts
index 53bc4e553f..31c065d4b4 100644
--- a/packages/backend/src/core/DriveService.ts
+++ b/packages/backend/src/core/DriveService.ts
@@ -407,7 +407,7 @@ export class DriveService {
);
if (this.meta.objectStorageSetPublicRead) params.ACL = 'public-read';
- if (this.meta.objectStorageEndpoint && this.meta.objectStorageEndpoint.includes('bunnycdn.com')) {
+ if (this.bunnyService.usingBunnyCDN(this.meta)) {
await this.bunnyService.upload(this.meta, key, stream);
} else {
await this.s3Service.upload(this.meta, params)
@@ -820,7 +820,7 @@ export class DriveService {
Bucket: this.meta.objectStorageBucket,
Key: key,
} as DeleteObjectCommandInput;
- if (this.meta.objectStorageEndpoint && this.meta.objectStorageEndpoint.includes('bunnycdn.com')) {
+ if (this.bunnyService.usingBunnyCDN(this.meta)) {
await this.bunnyService.delete(this.meta, key);
} else {
await this.s3Service.delete(this.meta, param);