Make a downloadable file available in an API that returns JSON

0

Hello,

I'm developing an API in Java. It is basically a java servlet that returns content in json (application / json). With a tomcat server. One of the answer fields is supposed to be a link to downloading a .txt file.

I do not know how. Any tips?

Writing to the file system every request looks like a killer, even though I have some cron to clean the directories with the files.

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

Thank you.

    
asked by anonymous 06.02.2018 / 18:03

1 answer

0

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

    
06.02.2018 / 20:35