Add Template Gallery support

This commit is contained in:
yu-i-i
2025-05-02 02:05:34 +02:00
parent 8b41eaddb8
commit a321b54502
68 changed files with 3098 additions and 63 deletions

View File

@@ -66,6 +66,11 @@ if (settings.filestore.stores.template_files) {
keyBuilder.templateFileKeyMiddleware,
fileController.insertFile
)
app.delete(
'/template/:template_id/v/:version/:format',
keyBuilder.templateFileKeyMiddleware,
fileController.deleteFile
)
}
app.get(

View File

@@ -6,7 +6,7 @@ import Errors from './Errors.js'
const { ConversionError } = Errors
const APPROVED_FORMATS = ['png']
const APPROVED_FORMATS = ['png', 'jpg']
const FOURTY_SECONDS = 40 * 1000
const KILL_SIGNAL = 'SIGTERM'

View File

@@ -111,7 +111,9 @@ async function _getConvertedFileAndCache(bucket, key, convertedKey, opts) {
let convertedFsPath
try {
convertedFsPath = await _convertFile(bucket, key, opts)
await ImageOptimiser.promises.compressPng(convertedFsPath)
if (convertedFsPath.toLowerCase().endsWith(".png")) {
await ImageOptimiser.promises.compressPng(convertedFsPath)
}
await PersistorManager.sendFile(bucket, convertedKey, convertedFsPath)
} catch (err) {
LocalFileWriter.deleteFile(convertedFsPath, () => {})