mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
support optional B2
service
This commit is contained in:
parent
7619c1f4d9
commit
0500118b68
@ -25,16 +25,23 @@ class API extends Server {
|
||||
cache: new CacheService(),
|
||||
redis: RedisClient(),
|
||||
storage: StorageClient(),
|
||||
b2Storage: new B2({
|
||||
applicationKeyId: process.env.B2_KEY_ID,
|
||||
applicationKey: process.env.B2_APP_KEY,
|
||||
}),
|
||||
b2Storage: null,
|
||||
limits: {},
|
||||
}
|
||||
|
||||
async onInitialize() {
|
||||
global.storage = this.contexts.storage
|
||||
global.b2Storage = this.contexts.b2Storage
|
||||
|
||||
if (process.env.B2_KEY_ID && process.env.B2_APP_KEY) {
|
||||
this.contexts.b2Storage = new B2({
|
||||
applicationKeyId: process.env.B2_KEY_ID,
|
||||
applicationKey: process.env.B2_APP_KEY,
|
||||
})
|
||||
|
||||
global.b2Storage = this.contexts.b2Storage
|
||||
} else {
|
||||
console.warn("B2 storage not configured on environment, skipping...")
|
||||
}
|
||||
|
||||
await this.contexts.db.initialize()
|
||||
await this.contexts.redis.initialize()
|
||||
|
@ -106,6 +106,10 @@ export default async ({
|
||||
|
||||
switch (service) {
|
||||
case "b2":
|
||||
if (!global.b2Storage) {
|
||||
throw new OperationError(500, "B2 storage not configured on environment, unsupported service. Please use `standard` service.")
|
||||
}
|
||||
|
||||
result = await b2Upload({
|
||||
remotePath,
|
||||
source,
|
||||
|
Loading…
x
Reference in New Issue
Block a user