This application demonstrates server-side file handling and streaming, allowing clients to download files via an Express server. The server handles file download requests to an external source and streams the content to the client, minimizing memory usage and efficiently handling large files.
- Node.js installed on your machine
- A
.env
file configured with necessary environment variables (if your application requires authentication for downloading files)
-
Clone this repository or download the source code.
-
Navigate to the project directory in your terminal.
-
Install dependencies by running:
npm install
-
Ensure your
.env
file is set up in the root of the project directory with the required environment variables.
-
Start the server with the following command:
node server.js
-
The server should now be running on
http://localhost:3000
.
Ensure test.html is implemented and it should reference download.js
for handling client-side download requests.
- See Example file -
test.html
Ensure download.js is implemented to make an HTTP request to the server's /download-doc endpoint (see server.js
) when the download button is clicked.
- See Example file -
download.js
- Open
test.html
in a web browser. - Click the "Download File" button to initiate the file download through the server.
If your application requires authentication or environment-specific variables, ensure they are correctly set up in your .env file and server configuration.
Adjust the server.js
, download.js
, and test.html
implementations as necessary to fit the specifics of your file download source and application requirements.