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
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:
parent
f42df5ca06
commit
3e83c7704c
1 changed files with 20 additions and 8 deletions
|
@ -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"
|
||||
|
|
Loading…
Add table
Reference in a new issue