Updating to make sure a relative URL is always used for attachments.
This commit is contained in:
parent
d508b905be
commit
30a7303762
|
@ -5,6 +5,7 @@ const fetch = require("node-fetch")
|
||||||
const PouchDB = require("../../../db")
|
const PouchDB = require("../../../db")
|
||||||
const CouchDB = require("pouchdb")
|
const CouchDB = require("pouchdb")
|
||||||
const { upload } = require("../../../utilities/fileSystem")
|
const { upload } = require("../../../utilities/fileSystem")
|
||||||
|
const { attachmentsRelativeURL } = require("../../../utilities")
|
||||||
|
|
||||||
// TODO: everything in this file is to be removed
|
// TODO: everything in this file is to be removed
|
||||||
|
|
||||||
|
@ -55,6 +56,7 @@ exports.prepareUpload = async function({ s3Key, bucket, metadata, file }) {
|
||||||
return {
|
return {
|
||||||
size: file.size,
|
size: file.size,
|
||||||
name: file.name,
|
name: file.name,
|
||||||
|
url: attachmentsRelativeURL(response.Key),
|
||||||
extension: [...file.name.split(".")].pop(),
|
extension: [...file.name.split(".")].pop(),
|
||||||
key: response.Key,
|
key: response.Key,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const env = require("../environment")
|
const env = require("../environment")
|
||||||
const { DocumentTypes, SEPARATOR } = require("../db/utils")
|
const { DocumentTypes, SEPARATOR } = require("../db/utils")
|
||||||
const CouchDB = require("../db")
|
const CouchDB = require("../db")
|
||||||
const { OBJ_STORE_DIRECTORY } = require("../constants")
|
const { OBJ_STORE_DIRECTORY, ObjectStoreBuckets } = require("../constants")
|
||||||
|
|
||||||
const BB_CDN = "https://cdn.app.budi.live/assets"
|
const BB_CDN = "https://cdn.app.budi.live/assets"
|
||||||
const APP_PREFIX = DocumentTypes.APP + SEPARATOR
|
const APP_PREFIX = DocumentTypes.APP + SEPARATOR
|
||||||
|
@ -157,3 +157,9 @@ exports.clientLibraryPath = appId => {
|
||||||
return `/api/assets/client`
|
return `/api/assets/client`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.attachmentsRelativeURL = attachmentKey => {
|
||||||
|
return exports.checkSlashesInUrl(
|
||||||
|
`/${ObjectStoreBuckets.APPS}/${attachmentKey}`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ const { ObjectStoreBuckets } = require("../constants")
|
||||||
const linkRows = require("../db/linkedRows")
|
const linkRows = require("../db/linkedRows")
|
||||||
const { cloneDeep } = require("lodash/fp")
|
const { cloneDeep } = require("lodash/fp")
|
||||||
const { FieldTypes, AutoFieldSubTypes } = require("../constants")
|
const { FieldTypes, AutoFieldSubTypes } = require("../constants")
|
||||||
const { checkSlashesInUrl } = require("./index")
|
const { attachmentsRelativeURL } = require("./index")
|
||||||
|
|
||||||
const BASE_AUTO_ID = 1
|
const BASE_AUTO_ID = 1
|
||||||
|
|
||||||
|
@ -187,9 +187,7 @@ exports.outputProcessing = async (appId, table, rows) => {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
row[property].forEach(attachment => {
|
row[property].forEach(attachment => {
|
||||||
attachment.url = checkSlashesInUrl(
|
attachment.url = attachmentsRelativeURL(attachment.key)
|
||||||
`${ObjectStoreBuckets.APPS}/${attachment.key}`
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue