React + Next.js download a file from server to client - reactjs

Im looking for a way to serve a PDF file so the users can download it by clicking on a button,Im using React and Next.js for SSR.
What would be the best approach for this?

placing the documents inside public folder and using the following a tag seems to work
<a download href="filename.pdf" > Get file </a>
I dont know if this is an ideal solution because those files are occupying space in the server,I was thinking about using a cdn,or maybe upload it to some kind of storaging service

Related

REACT: Play Videos with paths outside the public directory

I have an array of video paths that I want to play in REACT.
The issue is that the videos are outside of the public dir.
Any ideas on how to make this work?
If your link is a web URL, then you can use tag with href attribute to link your video on the web.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a
Ok, so I guess the problem boils down to the following statement -
"You want to serve a few videos saved in a particular directory of your server so that your react application can play them".
Well, in that case, it is somehow like you want to make these videos publically available, so why don't you just move them to a public dir, or make the directory they are in a public one, you can use any web server like nginx to do that. see the following link Use nginx to serve static files from subdirectories of a given directory.
Please note that this solution will make your videos public. If you want only authenticated users to access your video, you should consider making a video streaming api on your server see this link for how to do this in nodejs https://dev.to/abdisalan_js/how-to-code-a-video-streaming-server-using-nodejs-2o0

Adding local image in Jupyter SQL notebook

Started using Azure data studio and creating documentation for some SQL processes in our system.
As part of that I need to include a flow diagram in the document. Currently I have uploaded an image to a URL and am able to embed the image in document from the URL.
But is there any way to include an image from a local folder? Please assist.
I think this is what you want.
from IPython.display import Image
Image(filename='C:/your_path/your_image.PNG',width=200, height=100)
I was interested in this also. Syntax should be (if you store images in subfolder relative to notebook):
![ssms_subquery](images/16_ssms_subquery.png)
This didn't work for me initially: rendered as a broken image icon.
Things I tried:
Make sure you have a workspace defined for your root folder. Create the folder, then select "File > Add Folder to Workspace ..."
If that does nothing, try closing and restarting ADS. I've found the rendering to be flaky from time to time after awhile or if you have been opening/closing notebooks a lot.
Related topic has been discussed previously for markdown in general (but worth asking again for ADS!), eg. How to display local image in markdown

serve and excel template for download in angularjs

I have an AngularJs application and I am importing data from excel sheet. Now I have a Template which needs to be used for importing.
Please help me how do I serve the excel template for download using Angularjs.
Till now: I have a folder in the application called excel-template and in the UI i have provided Download.
It downloads the files but when I open it, it says that it is corrupted.
Thanks in advance.
You can use the anchor tag to serve excel template for download. Make sure the path is correct.
<a target="_self" href="excel-templates/XYZ.xlsx" download="XYZ.xlsx"><span>Download Template</span></a>

How to handle downloads in web component in codename one

I wrote a sample servlet which can serve by giving an option to download a pdf file. I want to download that pdf file in to my cn1 app through webBrowser component. Later I want to view that pdf in the browser itself. If possible can you share sample example.
Use the Util.downloadToFilesystemAPI giving a path you generate into the app home from the FileSystemStorage class.
Once download is complete you can just use Display.execute with that path.

dnn - upload an image to portal and use it in html module?

how do i upload an image to the portal and use it in my html of my html module?
i have an html module i want to use and part of it is an image. how do i upload to my portal and then reference the url where it is on my server inside my html?
In case you didn't see my comments on the other one. One way is to just find the file on the hard drive and figure out the link manually in relation to your web root. But if you are using this as a portal system then this might not be the best solution.
There is also upload option right withing html editor. click on image manager icon and it will give you the option to upload an image.
alt text http://images.devs-on.net/Image/rw5tTdgNRgs22f1-MyWebsiteHomeAlp.png
alt text http://images.devs-on.net/Image/YjlGTN1GTUVMR1p-MyWebsiteHomeAlp.png
If your HTML is being put in the DNN HTML module, you could also use the media picker baked in.
If you want a more integrated option, you could use the DNN FileManager API to accomplish integrated uploading and retrieving of files. The DNNFilePickerUploader might come in handy for this, which will give you a DNN file ID which you could the use to get the image url.

Resources