Provide a downloadable file in an API that returns JSON

Asked

Viewed 112 times

0

Hello,

I am developing a Java API. It is basically a java Servlet that returns content in json (application/json). With a Tomcat server. One of the response fields is supposed to be a link to the download of a . txt file.

I don’t know how to do it. Any tips?

Writing in the file system at each request seems me killer, even though I have some cron to clear directories with the files.

Some way to give a temporary link only while that request for a period without saving in the file system?

Thank you.

1 answer

0

The best way to do this is by using a service of Storage, as the firebase for example and will work as follows. You will configure the API in your project and upload the file in the firebase Storage. When you finish climbing, it will return a link to the file access as a response. then you store the link and use as you want.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.