我有用Python编写的aws识别代码,它由Node运行,它在Windows上运行得很好,但是当我在Linux上部署它时,我面临的问题是:- botocore.errorfactory.InvalidS3ObjectException: An error occurred (InvalidS3ObjectException) when calling the DetectText operation: Unable to get object metadata from S3. Check object key, region and/or access permissions.
我已经将AmazonRekognitionFullAccess和AmazonS3ReadOnlyAccess访问角色都赋予了我的用户。但我还是不知道该怎么做。
Python代码:-
bucket = 'image-test'
def image_to_dict(fileName, bucket):
client = boto3.client('rekognition', 'us-east-2')
response = client.detect_text(Image = { 'S3Object': { 'Bucket': bucket,
'Name': fileName } })
return response用于运行Python脚本的节点代码:-
var options = {
mode: 'text',
pythonPath:"/usr/bin/python2.7"
pythonOptions: ['-u'],
scriptPath: "/home/ubuntu/test",
args: [imageURl]
};
PythonShell.run('script.py', options, function (err, results) {
if (err)
throw err;
console.log("Data is: "+results)我在我的Ubuntu PIP10.0.1版本上安装了PythonVersion2.7。
发布于 2018-06-11 11:36:58
谢谢你的帮助。
这个问题背后的原因是,当我将图像名作为Node的参数传递时,由于某个Substring logic.So,当python与被操纵的名称一起在S3桶中搜索时,名称会被操纵,因为S3桶中不存在该名称。
https://stackoverflow.com/questions/50763441
复制相似问题