我正在尝试将CSV文件上传到AWS S3。我的代码没有语法错误,也不会导致任何异常,但CSV文件不会出现在Web控制台中。我还想按日期组织CSV文件。这是代码:
string[] files = Directory.GetFiles(folder, "*.csv*", SearchOption.TopDirectoryOnly);
foreach (string file in files)
{
PutObjectRequest request = new PutObjectRequest();
request.BucketName = "WorkFolder";
request.Key = "CSV/" + date + "/";
request.FilePath = file;
s3client.PutObject(request);
response = s3client.PutObject(request);
}
答案 0 :(得分:0)
我找到了答案。我错过了"文件名"在Key属性中。正确的代码如下:
PutObjectRequest request = new PutObjectRequest();
request.BucketName = "WorkFolder";
request.Key = "CSV/" + date + "/" + file; // where file is the name of the file
request.FilePath = s;
s3client.PutObject(request);