0

I have set up a REST API which allows to launch a spring batch job from a POST method that has the CSV at the input of the batch but I do not know how to make it feed because I can not write the csv in the src / main / resources of my project maven, I know that it is here that it must be written because in production the files that are present there will go in webapp / classes / to be used.

    byte[] fileBytes = Base64.decodeBase64(cleanFile);
    Files.write(Paths.get(getClass().getClassLoader().getResource("/").toURI()), fileBytes);

Generate that :

"message": "status 500 reading SalesClient#uploadCsv(Base64FileDTO); content:\n{\"timestamp\":1507151307711,\"status\":500,\"error\":\"Internal Server Error\",\"exception\":\"java.io.FileNotFoundException\",\"message\":\"class path resource [bonjour.csv] cannot be resolved to URL because it does not exist\",\"path\":\"/sales/upload\"}",

1 Answer 1

1

You'll need to write the file to some form of staging location. When working locally, a temp directory usually works well for this.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.