gpt4 book ai didi

ibm-watson - 使用watson-developer-cloud Node.js库的convert函数时,如何指定原文档的mime类型?

转载 作者:行者123 更新时间:2023-12-02 03:15:47 26 4
gpt4 key购买 nike

我正在使用 watson-developer-cloud Node.js 库将 HTML 文档发送到 Watson 的文档转换服务。该服务尝试猜测我正在发送的文档的 mime/类型,但有时会出错,因此我想在调用时明确指定 mime/类型。我知道文档转换服务的 REST API 有指定文档类型的方法,但是在 watson-developer-cloud 库中使用此调用时如何指定文档类型?下面的代码没有不要这样做。

//"content" is the actual HTML
document_conversion.convert({file: {value: new Buffer(content), options: {}},
conversion_target: "ANSWER_UNITS",
type: "text/html"
}, function (err, response) {...

最佳答案

file.options.contentType 技巧有效,但我刚刚更新了库以使其“得到官方支持”,语法更友好:

document_conversion.convert({
file: new Buffer(content),
content_type: "text/html",
conversion_target: "ANSWER_UNITS"
}, function (err, response) {
//...
});

这应该适用于 watson-developer-cloud v1.7.0 和更新版本。

关于ibm-watson - 使用watson-developer-cloud Node.js库的convert函数时,如何指定原文档的mime类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37147426/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com