brightsign / dev-cookbook

Templates, examples, and recipes for BrightSign devices 👩‍🍳
MIT License
9 stars 1 forks source link

Reading downloaded files from react #28

Closed octokrishna closed 5 months ago

octokrishna commented 5 months ago

Describe the bug When we download a file from node and it is stored in the default storage __dirname /storage/sd/dist. There seems to be no way for the react app to read that file.

To Reproduce Steps to reproduce the behavior:

  1. Create endpoint in the node application which downloads a video file (for example: /storage/sd/dist/default.mp4)
  2. Call the endpoint to download file, and after the video is downloaded use <video src="default.mp4"> tag to show the downloaded video.

Expected behavior The video should play after being downloaded from node.

Screenshots N/A

BrightSign Device (please complete the following information):

Additional context N/A

aleBranching commented 5 months ago

Hello, https://blog.j2i.net/2019/05/03/node-on-brightsign/ This blog here might help you start somewhere. You might need to use Nodejs fs module to read the file, as you'll see from the blog post you can call nodejs from index.html. I haven't tried a use case like yours but it should work.

octokrishna commented 5 months ago

Thanks! was able to figure it out.

Downloaded the file on node with node-file-downloader to /storage/sd/dist and used express to host the static directory /storage/sd/dist. And in react I could just go to the http://<Player_ip>:8020/downloaded_file.mp4 to show the file.