如何上传加密格式的文件 [英] How to upload a file in encrypted form

查看:176
本文介绍了如何上传加密格式的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发,将文件上传到亚马逊的应用程序。 Amazon提供 方法 WithServerSideEncryptionMethod(ServerSideEncryptionMethod.AES256)对文件进行加密,但它不能正常工作。它被保存文本为纯文本。

 公共静态无效UploadFile()
{
    新计划();
    VAR键=A;
    //键= ReplaceDblSlashToSingleFwdSlash(密钥);
    //路径= ReplaceFwdSlashToBackSlash(路径);
    VAR请求=新PutObjectRequest();
    request.WithBucketName(演示)
           .WithContentBody(我是塞纳 - 马恩省库马尔)
           .WithKey(钥匙)
           .WithServerSideEncryptionMethod(ServerSideEncryptionMethod.AES256);
    //request.PutObjectProgressEvent + = displayFileProgress;
    S3Response响应= s3Client.PutObject(要求);
    response.Dispose();
}
 

解决方案

您可以使用下面的code,以检查是否被加密或不..因为AWS S3他们的对象已经解密,当他们返回给你

这样试试下面的code,以检查对象在亚马逊S3

加密

  GetObjectMetadataRequest元=新GetObjectMetadataRequest();

GetObjectMetadataResponse响应= s3Client.GetObjectMetadata(甲基);
如果(response.ServerSideEncryptionMethod = ServerSideEncryptionMethod.AES256)
{
   //你的code到这里
}
 

我希望这可以帮助

I am developing an application that will upload files to Amazon. Amazon provides a method WithServerSideEncryptionMethod(ServerSideEncryptionMethod.AES256) to encrypt files but it is not working. It is saving text as a plain text.

public static void UploadFile()
{
    new Program();
    var key = "a";
    //key = ReplaceDblSlashToSingleFwdSlash(key);
    //path = ReplaceFwdSlashToBackSlash(path);
    var request = new PutObjectRequest();
    request.WithBucketName("demo")
           .WithContentBody("i am achal kumar")
           .WithKey(key)
           .WithServerSideEncryptionMethod(ServerSideEncryptionMethod.AES256);
    //request.PutObjectProgressEvent += displayFileProgress;
    S3Response response = s3Client.PutObject(request);
    response.Dispose();
}

解决方案

you can use the following code to check if the is encrypted or not .. because aws s3 they already decrypt the object when they return it to you.

so try the following code to check if the object is encrypted on amazon s3

GetObjectMetadataRequest meta = new GetObjectMetadataRequest();

GetObjectMetadataResponse response = s3Client.GetObjectMetadata(meta);
if(response.ServerSideEncryptionMethod = ServerSideEncryptionMethod.AES256)
{
   // your code goes here
}

i hope this could help

这篇关于如何上传加密格式的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆