如何解密存储在谷歌云存储中的.pgp文件



我有一个.pgp文件存储在谷歌云存储的bucket中。我想用私钥解密它,并将它存储回GCS中的新目标文件夹。我们有办法做到这一点吗?

无法直接在谷歌云存储(GCS(上进行更改,要解密和保存文件,必须下载文件,在本地解密并上传解密的文件。

我认为这段代码将对您的用例有用:

from google.cloud import storage
def download_blob(bucket_name, source_blob_name, local_file, destination_blob_name):
#bucket_name = "your-bucket-name"
#source_blob_name = "storage-object.pgp"
#local_file = "local/storage-object.pgp"
#Download your file from your bucket
storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
blob = bucket.blob(source_blob_name)
blob.download_to_filename(local_file)
# put your code to decrypt your file
#Upload your decrypted file from local
destination_blob_name= "/decrypted_files/storage-object.pgp"
blob = bucket.blob(destination_blob_name)
blob.upload_from_filename(local_file)

最新更新