【发布时间】:2017-06-06 23:35:52
【问题描述】:
vision.detectText() 在收到 google drive v3 以 webviewLink 格式从 drive.files.get() 获得的 URI 时阻塞
我的 webViewLink 抓取器是:
drive.files.get({
auth: auth,
fileId: options.fileID,
//fields: 'webContentLink' // <-- downloads the file
fields: 'webViewLink' // <-- "views" the file
},function(err, response) {}
response.webViewLink 格式为:
https://drive.google.com/file/d/0Bw4DMtLCtPMkOTlXR1l4Nkw1WGs/view?usp=drivesdk
vision.detectText(response.webViewLink) 窒息:
ERROR: { PartialFailureError: A failure occurred during this request.
at /Users/node_modules/@google-cloud/vision/src/index.js:434:15
at /Users/node_modules/@google-cloud/vision/src/index.js:126:5
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
errors:
[ { image: 'https://drive.google.com/file/d
/0Bw4DMtLCtPMkOTlXR1l4Nkw1WGs/view?usp=drivesdk',
errors: [Object] } ],
response: { responses: [ [Object] ] },
message: 'A failure occurred during this request.' }
用“传统”形式(如http://www.identifont.com/samples/houseindustries/NeutraText.gif)替换该 webViewLink URI 可以正常工作。
请注意https://cloud.google.com/vision/docs/request#providing_the_image sez 表示“您可以在请求中提供图片......作为可公开访问的 HTTP 或 HTTPS URL”。
对于 vision.detectText(),Drive v3 webViewLink 格式是否应该算作“可公开访问”?
如果不是,应如何修改此格式以使 vision.detectText() 可以接受以支持评估 google drive 托管的图像?
【问题讨论】:
-
我在下面添加了一个答案 - 但是
webContentLink会返回什么?那是文件网址吗? -
作为一种解决方法,“thumbnailLink”与 Cloud Vision 一起工作得非常好。不过,您需要从 URI 中删除“=s220”。
-
drive.google.com/uc?id=xxxx 即使公开也失败,就好像驱动器检测到云视觉并阻止它。