I have a simple React application created using create-react-app. I have an Azure Storage named storage1
, and a file share named share1
. Under share1
I have a couple of files, let's say file1.pdf
and file2.docx
.
How can I show the list of these files and download them in the React JS application?
You can use the below code to list the files from Azure file share and it downloads the file to your local environment.
First, you need to create a directory and add a file name with
api.js
andapp.js
.api.js
app.js
Next, In your react directory create
Filelist.js
FileList.js
Now we should run the backend code and it runs successfully as below,:
Then, I ran the frontend code and it also ran successfully as below,
And it opens in the browser like below. and it lists the files from Azure file share and you can click the download button to download the files.
Reference: Azure Storage File Share client library for JavaScript | Microsoft Learn