无法使用 ROR 向 abbyy 发送 business_card.png
Cant send a business_card.png to abbyy with ROR
我正在尝试一些新技术并了解 abbyy gem I created a free account on http://ocrsdk.com/plans-and-pricing/
我正在按照 gem
上的说明进行操作
class Client < ActiveRecord::Base
def abbyy
client = Abbyy::Client.new
client.process_business_card self.business_card, exportFormat: 'xml', imageSource: 'photo'
# Errno::ENOENT: No such file or directory - https://appname-dev.s3.amazonaws.com/uploads/client/business_card/1/bizcard.jpg
client.get_task_status
client.get
end
end
但是我收到了这个错误
Errno::ENOENT:没有那个文件或目录 - https://appname-dev.s3.amazonaws.com/uploads/client/business_card/1/bizcard.jpg
我确定我上传的目录是public
这是一个 link 演示应用程序 https://github.com/mzaragoza/abbyy
将 require 'open-uri'
添加到文件的顶部。
然后下载文件,然后才给abby:
def abby
require 'tempfile'
card = Tempfile.new('business_card')
card.binmode
stream = open(self.business_card.url)
card.write(stream.read)
stream.close
card.close
client = Abbyy::Client.new
client.process_business_card card.path, exportFormat: 'xml', imageSource: 'photo'
client.get_task_status
client.get
ensure
# ensuring every handle is closed, and ignoring exceptions, which could arise if handles already closed
# or haven't been opened
stream.close rescue nil
card.close rescue nil
card.unlink rescue nil
end
我正在尝试一些新技术并了解 abbyy gem I created a free account on http://ocrsdk.com/plans-and-pricing/
我正在按照 gem
上的说明进行操作class Client < ActiveRecord::Base
def abbyy
client = Abbyy::Client.new
client.process_business_card self.business_card, exportFormat: 'xml', imageSource: 'photo'
# Errno::ENOENT: No such file or directory - https://appname-dev.s3.amazonaws.com/uploads/client/business_card/1/bizcard.jpg
client.get_task_status
client.get
end
end
但是我收到了这个错误
Errno::ENOENT:没有那个文件或目录 - https://appname-dev.s3.amazonaws.com/uploads/client/business_card/1/bizcard.jpg
我确定我上传的目录是public
这是一个 link 演示应用程序 https://github.com/mzaragoza/abbyy
将 require 'open-uri'
添加到文件的顶部。
然后下载文件,然后才给abby:
def abby
require 'tempfile'
card = Tempfile.new('business_card')
card.binmode
stream = open(self.business_card.url)
card.write(stream.read)
stream.close
card.close
client = Abbyy::Client.new
client.process_business_card card.path, exportFormat: 'xml', imageSource: 'photo'
client.get_task_status
client.get
ensure
# ensuring every handle is closed, and ignoring exceptions, which could arise if handles already closed
# or haven't been opened
stream.close rescue nil
card.close rescue nil
card.unlink rescue nil
end