fix: voice message
All checks were successful
/ build (map[dockerfile:./services/tasks/Dockerfile name:tasks]) (push) Successful in 2m20s
/ build (map[dockerfile:./services/web/Dockerfile name:web]) (push) Successful in 2m35s
/ build (map[dockerfile:./services/api/Dockerfile name:api]) (push) Successful in 1m5s
/ build (map[dockerfile:./services/app/Dockerfile name:app]) (push) Successful in 1m43s
/ build (map[dockerfile:./services/watchers/Dockerfile name:watchers]) (push) Successful in 2m27s
/ build (map[dockerfile:./services/files/Dockerfile name:files]) (push) Successful in 2m45s
/ build (map[dockerfile:./services/hasura/Dockerfile name:hasura]) (push) Successful in 2m48s
/ deploy (push) Successful in 16s

This commit is contained in:
Jo 2025-08-09 15:39:29 +02:00
parent f42df5ca06
commit 3e83c7704c
Signed by: devthejo
GPG key ID: 00CCA7A92B1D5351

View file

@ -38,25 +38,37 @@ module.exports = function () {
"id"
`
const incomingType = (file?.mimetype || "").toLowerCase()
const nameFromClient = (file?.originalname || "").toLowerCase()
const mappedType =
incomingType === "audio/m4a"
? "audio/mp4"
: incomingType && incomingType.startsWith("audio/")
? incomingType
: ""
const guessedFromName = nameFromClient.endsWith(".m4a") ? "audio/mp4" : ""
const contentType = mappedType || guessedFromName || "audio/mp4"
const metaData = {
"Content-Type": file.mimetype,
encoding: file.encoding,
originalname: file.originalname,
userId,
deviceId,
"Content-Type": contentType,
"Content-Disposition": `inline; filename="${audioFileUuid}.m4a"`,
"Cache-Control": "public, max-age=31536000, immutable",
"x-amz-meta-encoding": file.encoding,
"x-amz-meta-originalname": file.originalname,
"x-amz-meta-userid": String(userId),
"x-amz-meta-deviceid": String(deviceId),
}
await minio.ensureBucketExists(bucket)
try {
const res = await minio.putObject(
"audio",
audioFileUuid,
bucket,
`${audioFileUuid}.m4a`,
file.buffer,
file.size,
metaData
)
// logger.trace(res)
logger.debug(
{ res, bucket, audioFileUuid, userId, deviceId },
"Successfully uploaded audio file"