如何使用 HapiJs API 接受多部分类型的有效载荷?

How to accept payload of multipart type using HapiJs API?

我已经使用 Nodejs 模块 Hapijs 实现了一个 POST API。当我使用邮递员使用 'form-data' 类型传递图像时,出现以下错误:

{"statusCode":400,"error":"Bad Request","message":"Invalid multipart payload format"}

如果有人有相同的解决方案,请帮忙。谢谢。

使用此格式这肯定适合您 maxBytes 是您希望上传的最大字节数的大小。

 payload:{
            maxBytes:30485760,
            parse: true,
            output: 'file',
            allow: 'multipart/form-data'
        },
        validate: {
            payload: {
                accessToken: Joi.string().required(),

                profilePic: Joi.any()
                    .meta({swaggerType: 'file'})
                    .description('image file')
                    .required(),


            }