您好,夏普方法返回我的“无效输入”
当我使用尖锐的功能时,我会得到“无效的输入”。 我知道这是
import { BadRequestException, Injectable, PipeTransform } from '@nestjs/common';
import * as path from 'path';
import * as sharp from 'sharp'
@Injectable()
export class SharpPipe implements PipeTransform<Express.Multer.File, Promise<string>> {
async transform(image: Express.Multer.File): Promise<string> {
const originalName = path.parse(image.originalname).name;
const filename = Date.now() + '-' + originalName + '.webp';
await sharp(image.buffer)
.resize(800)
.webp({effort: 3})
.toFile(path.join('uploads', filename));
return filename;
}
}
一个问题是尖锐的方法。帮我
when i use sharp function, i get "Invalid Input". Here is the code
import { BadRequestException, Injectable, PipeTransform } from '@nestjs/common';
import * as path from 'path';
import * as sharp from 'sharp'
@Injectable()
export class SharpPipe implements PipeTransform<Express.Multer.File, Promise<string>> {
async transform(image: Express.Multer.File): Promise<string> {
const originalName = path.parse(image.originalname).name;
const filename = Date.now() + '-' + originalName + '.webp';
await sharp(image.buffer)
.resize(800)
.webp({effort: 3})
.toFile(path.join('uploads', filename));
return filename;
}
}
i know that a problem is into sharp method. Help me guys
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
缓冲区属性仅对您使用
MemoryStorage
对Multer有效。使用{存储:multer.memorystorage()}
设置Multer Init选项可能会解决您的问题。The buffer property is only valid on you are using the
MemoryStorage
for the multer. Set the multer init options with{storage:multer.MemoryStorage()}
may fix your problem.