I'm trying to download a .gz file from a NEXRAD (Next Generation Weather Radar) api with Spring Boot. Here is the original link: https://noaa-nexrad-level2.s3.amazonaws.com
And this is the link where the file gets downloaded automatically on hitting it: https://noaa-nexrad-level2.s3.amazonaws.com/1991/06/05/KTLX/KTLX19910605_162126.gz
Here is the website which gives info about NEXRAD:
https://github.com/awslabs/open-data-docs/tree/main/docs/noaa/noaa-nexrad
I'm quite new to Spring Boot and I first tried hitting a random countries url and getting a json. Here is the code I wrote for it:
@RestController
public class ApiController {
@Autowired
private RestTemplate restTemplate;
private static String url = "https://restcountries.com/v3.1/all";
@GetMapping("/countries")
public List<Object> getCountries() {
Object[] countries = restTemplate.getForObject(url, Object[].class);
return Arrays.asList(countries);
}
This code works correctly where I'm able to get a json displayed on the browser on hitting the /countries url and appending it to localhost.
But now I want to hit the NEXRAD url and download the .gz file. Can anyone help on that?