amazon-s3-select - botocore.exceptions.ClientError:调用 SelectObjectContent 操作时发生错误(InvalidTextEncoding)
问题描述
通过python执行下面的代码时
response= S3.select_object_content(Bucket=S3_bucket_name,Key=S3_file_Key,ExpressionType='SQL', Expression="select count(*) from s3object", InputSerialization={'CSV': {"FileHeaderInfo": header_usage},'CompressionType':compressformat}, OutputSerialization={'CSV': {}},)
我收到类似的错误
回溯(最近一次通话最后):
File OutputSerialization={'CSV': {}},)
File "/usr/local/lib/python2.7/site-packages/botocore/client.py", line 320, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python2.7/site-packages/botocore/client.py", line 623, in _make_api_call
raise error_class(parsed_response, operation_name)
**ClientError: An error occurred (InvalidTextEncoding) when calling the SelectObjectContent operation: UTF-8 encoding is required. The text encoding error was found near byte 49,152.**
我在 boto3 中搜索了 Invalid text Encoding 但找不到。你能帮我检查一下吗?
提前致谢
解决方案
您希望收到的数据有错误的输出序列化。输出序列化描述您希望 Amazon S3 作为响应返回的数据格式,并且您要求它返回编码错误的格式。我自己无法测试您的代码,因为我只有一小部分,但您需要将您的序列化输出编码为 utf-8 格式,否则 Amazon S3 存储服务无法序列化您的响应。可能您需要扩展OutputSerialization={'CSV': {}}
以确保您的响应以 UTF-8 格式编码。
也许这些资源可以帮助你:
推荐阅读
- javascript - 如何使用 NodeJS 在 selenium-webdriver 中选择下拉值
- keras - 使用 Keras 的 ELMo 嵌入层中 variable_scope 的问题
- java - 来自数据库的具有字段、值和数据类型的动态 Java 对象
- vba - 在当前发送电子邮件中通过 Active Explorer 获取当前正文
- azure - 需要通过 REST API 了解 Azure 中的运行命令
- javascript - 开玩笑 - 如果调用了多个函数,如何使用期望一次来断言
- ios - 在不使用 alpha 的情况下使用 UISegmentedControl 在视图 ios 之间切换?
- java - Selenium Webdriver Java 中的 JavascriptExecutor
- gradle - 想清理根目录下的 .gradle 文件夹,我可以安全地删除以前的旧版本文件夹吗?
- javascript - 每次用户进入我的网站时,如何更改我的年龄验证以清除 cookie?