I have a properties.yml file , with the information shown below:
clave:
location: "ap"
apiKey: "QmZ6LvNqzsSSgTTLj1k7ncbaVRumlJ5XgBvadf_7MQaH"
the information is called from a controller, which has the following information:
@RestController
@RequestMapping("/file")
public class StorageController {
@Autowired
StorageConfig storageConfig;
@Autowired
StorageService storageService;
@Value("${clave.apiKey}")
private String apiKey;
@Value("${clave.serviceInstanceId}")
private String serviceInstanceId;
@Value("${clave.endpointUrl}")
private String endpointUrl;
@Value("${clave.location}")
private String location;
AmazonS3 client = storageConfig.createClient(apiKey, "crn:v1:bluemix:public:cloud-object-storage:global:a/ef304b2c20b5447eac59a8bb3e85812c:15494859-a02d-45d7-9803-e24c7dfcd5fc::", "https://s3.ap.cloud-object-storage.appdomain.cloud", location);
@PostMapping("/upload") // //new annotation since 4.3
public String singleFileUpload(@RequestParam("file") MultipartFile file) {
try {
storageService.uploadFile(client, file);
} catch (Exception e) {
e.printStackTrace();
}
return "redirect:/uploadStatus";
}
}
And it happens that I get an error when I call the apiKey, which I have created in properties. Whereas when I make the location call, it doesn't give me a problem in the createClient method.
Do you know if I'm making a mistake when calling the data? o Is there another way to make the call? I appreciate the help.