检查node.js中的instanceof文件

时间:2018-09-16 23:34:00

标签: node.js express

我正在验证从客户端到服务器端的传入数据,客户端正在将File实例发送到服务器。我想使用node.js验证该实例。除了在评估TypeError: Right-hand side of 'instanceof' is not an object时,node.js抛出myPassedFileInstance instanceof File

如何在node.js中验证文件实例?

1 个答案:

答案 0 :(得分:0)

File接口不是Javascript(node.js)的一部分,它属于Web API。 More information about File

因此File在您的node.js应用程序中不可用。

也许您可以在请求的标头中使用content-type来检查请求是否为某种类型的文件或流。