Fixing an issue with the upload URL not being inserted in correct location.

This commit is contained in:
mike12345567 2021-05-12 14:27:33 +01:00
parent 3e63c616d3
commit a289493224
1 changed files with 6 additions and 5 deletions

View File

@ -118,16 +118,17 @@ exports.upload = async function (ctx) {
// add to configuration structure
// TODO: right now this only does a global level
const db = new CouchDB(GLOBAL_DB)
let config = await getScopedFullConfig(db, { type })
if (!config) {
config = {
let cfgStructure = await getScopedFullConfig(db, { type })
if (!cfgStructure) {
cfgStructure = {
_id: generateConfigID({ type }),
config: {},
}
}
const url = `/${bucket}/${key}`
config[`${name}Url`] = url
cfgStructure.config[`${name}Url`] = url
// write back to db with url updated
await db.put(config)
await db.put(cfgStructure)
ctx.body = {
message: "File has been uploaded and url stored to config.",