Node.JS textract read file stream stored in SQL Server

I have a SQL Server table with a column called Attachment of data type NVARCHAR(MAX) . I upload some PDF/Docx file into the field for different rows base on certain criteria. Here is the statement I upload the file into db

UPDATE dbo.[Document] 
SET Attachment = (SELECT BulkColumn FROM OPENROWSET(BULK N'E:1.pdf', SINGLE_BLOB) blob) 
WHERE ID = 1; 

The upload is successful. My purpose is to use textract or any other similar tool to read the underlying text from the attachment. I see there're a few APIs. As there is no file nor URL involved, I'm guessing the correct API should be Buffere + MIME type, but what exact is a MIME type for PDF and Docx? I tried to put in "application/pdf" for PDF and "application/vnd.openxmlformats-officedocument.wordprocessingml.document" for docx and I get errors:

[Error: Incorrect parameters passed to textract.]

What should be the correct value for the MIME type in this case? or this shouldn't be treated as a buffer? If then what should be the correct API to use?

I'm able to use textract to open the actual physical file and read the contents though.

Appreciate if anyone can advise on this matter.

链接地址: http://www.djcxy.com/p/45544.html

上一篇: LINQ to SQL:加载处理延迟加载的关联

下一篇: Node.JS textract读取存储在SQL Server中的文件流