Skip to content

It helps you to actually trigger download of any file available on any server, and avoiding opening of the file in browser.

License

Notifications You must be signed in to change notification settings

VishwaGauravIn/trigger-download-file-pro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

trigger-download-file-pro

It helps you to actually trigger download of any file available on any server, and avoiding opening of the file in browser.

How to Use ?

There are 2 ways to use it

First:

Just create anchor tag <a> and provide link in this format
https://triggerdownload.herokuapp.com/api/download?url=YOUR_URL&filename=FILE_NAME&format=FILE_FORMAT

Required Parameters

url = Your download URL
filename = File Name for Downloaded file
format = format/extension of the file that you want to download

Example 1:

Simple Example

<a href="https://triggerdownload.herokuapp.com/api/download?url=https://ytdlpro.herokuapp.com/def_thumb.jpg&filename=logo&format=jpg">Click to Trigger Download!</a>

Example 2:

Pro Example , incase you need to pass url that contains & , we will just encode the url and then pass it. Let's assume you have to download from this url https://avatars.githubusercontent.com/u/81325730?v=4 then we will first use encodeURIComponent to remove the & from URL and then pass it in anchor tag.
Simple HTML

<a href="https://triggerdownload.herokuapp.com/api/download?url="+url+"&filename=test&format=jpg">Click to Trigger Download!</a>
<script>
  const url = encodeURIComponent(https://avatars.githubusercontent.com/u/81325730?v=4)
</script>

React/NextJS

<a href="https://triggerdownload.herokuapp.com/api/download?url="+encodeURIComponent(https://avatars.githubusercontent.com/u/81325730?v=4)+"&filename=test&format=jpg">Click to Trigger Download!</a>

Similary, you can also pass variable as filename and format !

Second:

You can copy download.js file from public/api folder of this repository and use it as your own API and you can also customise it as per your choice.

ENJOY!

Releases

No releases published

Packages

No packages published