[英]How to get file extension from file content using Node.js
I need one help.我需要一个帮助。 I need to fetch what the file type should be from the file content only using Node.js.
我需要仅使用 Node.js 从文件内容中获取文件类型。 I am exaplining the scenario below.
我正在解释下面的场景。
Lets say I have some content like below.可以说我有一些如下内容。
let fileContent = "The textContent property sets or returns the text content of the specified node, and all its descendants."
If we can see here the variable fileContent
has some text data and I want to write this data into one file.如果我们可以在这里看到变量
fileContent
有一些文本数据,我想将这些数据写入一个文件。 So for that I need to create the file with proper extension like abc.txt
.因此,为此我需要创建具有适当扩展名的文件,例如
abc.txt
。 Similarly If fileContent
has some json
data then I will create the file like abc.json
and write the value inside it.同样,如果
fileContent
有一些json
数据,那么我将创建abc.json
之类的文件并将值写入其中。
So here I need to fetch what should be the type
of file from this content only using Node.js
.因此,在这里我需要仅使用
Node.js
从此内容中获取文件的type
。 If anybody has solution for this will be great help.如果有人对此有解决方案,将有很大帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.