I am trying to fetch from S3 bucket but I am getting key as null.
Here is my code :
@Value("${base.location}")
private String keyname;
@Value("${os.s3.key}")
private String fileName;
@Autowired
ReadFromS3 readFromS3;
StringBuilder fileURI = new StringBuilder(keyname);
fileURI.append(fileName);
InputStream ts = readFromS3.getResourceStream(fileURI.toString()); //null Pointer Exception
Here is my application.properties file
base.location=option/output_files
os.s3.key =${S3_KEYNAME}
S3_KEYNAME =MY_FILE.txt
Here is my getResourceStream method
@Override
public InputStream getResourceStream(String keyName) {
S3ObjectInputStream s3objectStream = s3client.getObject(new GetObjectRequest(bucketName, keyName))
.getObjectContent();
return s3objectStream; // The specified key does not exist.
}
I added Loggers and the keyname is option/output_files/MY_FILE.txt
I don't understand what it means with the "specified key".