-2

I am kinda newbie to this so I got not idea. Explanation:

I got an web app (front end made in JavaScript/Reactjs) and an backend (with Java using Liferay API)

Server has files (File A, B, C, etc. Any kind of file: pdf, excel, audio, txt, etc) these files are in a different location from the backend.

Each file has its own “ID” when I called the file from the java backend, I called like this: https://url-server.com?id=123456789 this automatically triggers a download. The URL is protected with an authentication method. I do not have access to this server with the files. I can only use this endpoint with ID as parameter.

The goal: streaming this file directly to the user (such as https://web-app.com/anotherNameForFile.txt obviously is just mapping the url from the original server with different name file) to the browser, so the user can “see” or use the file in the browser, but not be able to download the file to the PC. Kinda like Spotify or Netflix does. The file will still be kept in the server, streamed to the user and without option to download or copy the file the user is seeing in the app/browser.

Questions: How to do this? What would be the best approach? How to do the streaming and how to do it without the user be able to save the file? Any comments or even code example would be much appreciated.

  • 1
    This question is a lot too broad to be on topic on stackoverflow (see [help/on-topic]). There are other sites in the Stackexchange network where it'll be on topic. Once you know how to solve your problem in general, and you have a concrete problem with code, it's good here. But prepare for the problem to be inherently unsolvable with a browser. If you deliver content to the client, it's in their hands. – Olaf Kock Apr 20 '21 at 07:24

1 Answers1

1

I would say that you could draw inspiration from this thread: Web Audio- streaming file from server to client

Beyond that, a simple way could be to interface this into your HTML code with the <audio> tag. If you want a solution using ReactJS, then you would want to make a script that strictly plays the audio via input with a component. Some inspiration can be drawn through this alternate thread: Playing sound in React.js