0

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?

CuriousLearner
  • 421
  • 4
  • 14

1 Answers1

0

You'll need a separate endpoint to download the file. Please have a look at the accepted answer to this question: download a file from Spring boot rest service

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 23 '22 at 07:04