commit
e053409050
|
@ -57,6 +57,7 @@
|
|||
"electron-updater": "^4.3.1",
|
||||
"fix-path": "^3.0.0",
|
||||
"fs-extra": "^8.1.0",
|
||||
"jimp": "^0.16.1",
|
||||
"joi": "^17.2.1",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"koa": "^2.7.0",
|
||||
|
@ -74,7 +75,6 @@
|
|||
"pouchdb-all-dbs": "^1.0.2",
|
||||
"pouchdb-replication-stream": "^1.2.9",
|
||||
"sanitize-s3-objectkey": "^0.0.1",
|
||||
"sharp": "^0.26.0",
|
||||
"squirrelly": "^7.5.0",
|
||||
"tar-fs": "^2.1.0",
|
||||
"uuid": "^3.3.2",
|
||||
|
|
|
@ -163,15 +163,14 @@ exports.serveApp = async function(ctx) {
|
|||
|
||||
exports.serveAttachment = async function(ctx) {
|
||||
const appId = ctx.user.appId
|
||||
|
||||
const attachmentsPath = resolve(budibaseAppsDir(), appId, "attachments")
|
||||
|
||||
// Serve from CloudFront
|
||||
if (process.env.CLOUD) {
|
||||
const S3_URL = `https://cdn.app.budi.live/assets/${appId}/attachments/${ctx.file}`
|
||||
|
||||
const response = await fetch(S3_URL)
|
||||
const body = await response.text()
|
||||
ctx.set("Content-Type", response.headers.get("Content-Type"))
|
||||
ctx.body = body
|
||||
return
|
||||
}
|
||||
|
|
|
@ -1,24 +1,21 @@
|
|||
const fs = require("fs")
|
||||
const sharp = require("sharp")
|
||||
const jimp = require("jimp")
|
||||
const fsPromises = fs.promises
|
||||
|
||||
const FORMATS = {
|
||||
IMAGES: ["png", "jpg", "jpeg", "gif", "svg", "tiff", "raw"],
|
||||
IMAGES: ["png", "jpg", "jpeg", "gif", "bmp", "tiff"],
|
||||
}
|
||||
|
||||
async function processImage(file) {
|
||||
const imgMeta = await sharp(file.path)
|
||||
.resize(300)
|
||||
.toFile(file.outputPath)
|
||||
return {
|
||||
...file,
|
||||
...imgMeta,
|
||||
}
|
||||
function processImage(file) {
|
||||
return jimp.read(file.path).then(img => {
|
||||
return img.resize(300, jimp.AUTO).write(file.outputPath)
|
||||
})
|
||||
}
|
||||
|
||||
async function process(file) {
|
||||
if (FORMATS.IMAGES.includes(file.extension.toLowerCase())) {
|
||||
return await processImage(file)
|
||||
await processImage(file)
|
||||
return file
|
||||
}
|
||||
|
||||
// No processing required
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue