在编码'utf-8'并从amazon-s3存储桶中读取文件时,我遇到了问题.
我创建了一个文件.
file = File.open('new_file', 'w', :encoding => 'utf-8')
string = "Some ££££ sings"
file.write(string)
file.close
Run Code Online (Sandbox Code Playgroud)
从本地读取一切都没问题.
open('new_file').read
=> "Some ££££ sings"
Run Code Online (Sandbox Code Playgroud)
现在我使用aws_s3将文件上传到amazon s3.
AWS::S3::S3Object.store('new_file', open('new_file'), 'my_bucket')
=> #<AWS::S3::S3Object::Response:0x2214462560 200 OK>
Run Code Online (Sandbox Code Playgroud)
当我从亚马逊s3读
AWS::S3::S3Object.find('new_file', 'my_bucket').value
=> "Some \xC2\xA3\xC2\xA3\xC2\xA3\xC2\xA3 sings"
open(AWS::S3::S3Object.find('new_file','my_bucket').url).read
=> "Some \xC2\xA3\xC2\xA3\xC2\xA3\xC2\xA3 sings"
Run Code Online (Sandbox Code Playgroud)
我一直在尝试许多仍然无法找到解决方案的东西.
中号