DEV Community

Dean
Dean

Posted on • Originally published at veducate.co.uk on

Download Releases from Github using Curl and Wget

The issue

I was trying to download a software release from GitHub using Curl and hitting an issue, the file wasn’t large enough for a start, it was unusable and clearly not the file I expected.

curl -O https://github.com/kastenhq/external-tools/releases/download/3.0.12/k10tools_3.0.12_linux_amd64

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 635 100 635 0 0 2387 0 --:--:-- --:--:-- --:--:-- 2387
Enter fullscreen mode Exit fullscreen mode

I tested this in a browser and found the link redirects elsewhere, hence the issue.

The Fix

Just needed to specify a few extra arguments.

curl -LJO https://github.com/kastenhq/external-tools/releases/download/3.0.12/k10tools_3.0.12_linux_amd64

# Explanation of the arguments

-L, --location Follow redirects
-J, --remote-header-name Use the header-provided filename
-O, --remote-name Write output to a file named as the remote file
Enter fullscreen mode Exit fullscreen mode

If you wish to use wget instead.

wget --content-disposition https://github.com/kastenhq/external-tools/releases/download/3.0.12/k10tools_3.0.12_linux_amd64

# Explanation of the argument 
--content-disposition honor the Content-Disposition header when choosing local file names (EXPERIMENTAL)

Enter fullscreen mode Exit fullscreen mode

Regards

Follow @Saintdle

Dean Lewis

The post Download Releases from Github using Curl and Wget appeared first on vEducate.co.uk.

Top comments (0)