我正在处理S3中的非常大的文件,这些文件需要解密并保存回S3。我们的磁盘空间和内存是有限的,所以流媒体是我们最好的选择。
我使用的是ruby-gpgme gem。
这是我到目前为止所知道的:
require 'gpgme'
require 'aws-sdk'
s3_credentials = Aws::Credentials.new(AWS_ACCESS_KEY_ID, AWS_SECRET_KEY_ID)
s3_client = Aws::S3::Client.new(credentials: s3_credentials)
source_file = 'in_file.gpg'
object_key = "upload/#{source_file}"
destination = File.open('out.txt', 'w+b')
crypto = GPGME::Crypto.new
source = File.open(source_file)
s3_client.get_object(bucket: bucket, key: object_key) do |chunk|
crypto.decrypt(chunk, password: password, output: destination)
end
# As a follow-up, I will setup the script to stream directly back out to S3
# S3.get_object > GPG.decrypt > S3.upload_part这将成功解密并写入第一个块,但在处理下一个块之前解密失败。
我假设这是因为第一个块没有正确终止,并且.decrypt没有连续地从流本身读取。
关于如何将数据块作为流进行解密,有什么想法吗?
发布于 2018-06-28 21:00:10
https://stackoverflow.com/questions/48484749
复制相似问题