fix(Media): don't resize videos
This commit is contained in:
parent
89819885d6
commit
e6383d64c8
1 changed files with 10 additions and 2 deletions
|
@ -46,6 +46,9 @@ export default class MediaService {
|
||||||
}
|
}
|
||||||
|
|
||||||
static multer(type: string, multiple: boolean = false) {
|
static multer(type: string, multiple: boolean = false) {
|
||||||
|
// I whished I had a more simple a reliable way to do it
|
||||||
|
// it's a global variable
|
||||||
|
let isVideo: boolean = false
|
||||||
let instance = multer({
|
let instance = multer({
|
||||||
storage: multerS3({
|
storage: multerS3({
|
||||||
s3: MediaService.getS3(),
|
s3: MediaService.getS3(),
|
||||||
|
@ -53,6 +56,8 @@ export default class MediaService {
|
||||||
acl: 'public-read',
|
acl: 'public-read',
|
||||||
contentType: multerS3.AUTO_CONTENT_TYPE,
|
contentType: multerS3.AUTO_CONTENT_TYPE,
|
||||||
transforms: () => {
|
transforms: () => {
|
||||||
|
// don't transform a video
|
||||||
|
if (isVideo) { return null }
|
||||||
let transformOptions = {}
|
let transformOptions = {}
|
||||||
let quality = 80
|
let quality = 80
|
||||||
if (type === 'media') {
|
if (type === 'media') {
|
||||||
|
@ -76,7 +81,9 @@ export default class MediaService {
|
||||||
key: (_: any, file: any, cb: any) => {
|
key: (_: any, file: any, cb: any) => {
|
||||||
// generate a random id for this image
|
// generate a random id for this image
|
||||||
let r = Math.random().toString(36).substring(4).toUpperCase()
|
let r = Math.random().toString(36).substring(4).toUpperCase()
|
||||||
console.log(r, file)
|
// special string from the frontend to kown if it is a video
|
||||||
|
isVideo = file.originalname.indexOf('||%_FORMAT_VIDEO_%||') !== -1
|
||||||
|
console.log(r, file, isVideo)
|
||||||
cb(null, r + '_' + type)
|
cb(null, r + '_' + type)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -94,8 +101,9 @@ export default class MediaService {
|
||||||
location: file.location.replace('http://', 'https://'),
|
location: file.location.replace('http://', 'https://'),
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
size: file.size,
|
size: file.size,
|
||||||
|
// we will remove the special substr from the front end
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
originalFileName: file.originalname,
|
originalFileName: file.originalname.replace('||%_FORMAT_VIDEO_%||', ''),
|
||||||
type: type === 'media' ? file.contentType.split('/')[0] : type
|
type: type === 'media' ? file.contentType.split('/')[0] : type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue