我正在黄瓜中测试测试,我想将文件从testData上传到S3存储桶:
String bucket = bucketname+ "/ADL";
String ActualFilesPathForComparison = Environment.getInstance().getValue(DATAINPUTPATH);
temp = ActualFilesPathForComparison+inputPath+ File.separator+ file;
s3.uploadFile(bucket, file, new File (temp));
public void uploadFile(String bucketName, String fileKeyName, File localFilePath) {
try {
this.s3.putObject((new PutObjectRequest(bucketName, fileKeyName, localFilePath)).withCannedAcl(CannedAccessControlList.PublicRead));
} catch (Exception var5) {
throw new RuntimeException("Upload file failed.", var5);
}
}
我有这个文件:
src\main\resources\testData\testInputsFile\testLZInputUnZippedFiles\Log.csv
当我运行测试时,我从调试中得到了
localFilePath = testData\testInputsFile\testLZInputUnZippedFiles\Log_WithHeader.csv
并得到排他:
com.amazonaws.SdkClientException: Unable to calculate MD5 hash: testData\testInputsFile\testLZInputUnZippedFiles\Log_WithHeader.csv (The system cannot find the path specified)
我应该解决什么?我想避免将文件从src复制到外部。
答案 0 :(得分:0)
要访问src/main/resources/
内部的名为“ my.properties”的文件,只需执行以下操作:
File propertiesFile = new File(this.getClass().getClassLoader().getResource("my.properties").getFile());