Uly.me

cloud engineer

  • Home
  • About
  • Archives
Home/Archives for download

October 2, 2019

GCP Increase Download Speed for gsutil

If you’re downloading large files, you can speed up download speeds by modifying gsutil. Decrease the number of threads and increase the number of components.

gsutil \
-o "GSUtil:parallel_thread_count=1" \
-o "GSUtil:parallel_process_count=8" \
cp gs://bucket/source.dat /download/dest/file.dat

gsutil \ -o "GSUtil:parallel_thread_count=1" \ -o "GSUtil:parallel_process_count=8" \ cp gs://bucket/source.dat /download/dest/file.dat

March 11, 2019

Local RPM Install

Steps for creating a local RPM package installation.

# download plugin
yum install yum-plugin-downloadonly
# download package and dependencies
yum install --downloadonly reiserfs
# download package and dependencies to a specific directory
yum install --downloadonly --downloaddir=/home/ec2-user package
# download multiple packages
yum install --downloadonly --downloaddir=/root/mypackages/ package1 package2
# finally install package
rpm -ivh -r /home/ec2-user package.rpm

# download plugin yum install yum-plugin-downloadonly # download package and dependencies yum install --downloadonly reiserfs # download package and dependencies to a specific directory yum install --downloadonly --downloaddir=/home/ec2-user package # download multiple packages yum install --downloadonly --downloaddir=/root/mypackages/ package1 package2 # finally install package rpm -ivh -r /home/ec2-user package.rpm

July 24, 2016

How To Force Downloads

Browsers behave differently when it comes to linking media files. Sometimes it will play them directly on the browser. Sometimes it will download them. Each browser seems to have their own rules. So, how do we force all browsers to download media files with just a click of a link.

A simple link like the one below simply won’t work.

<a href="video.mp4">Download</a>

<a href="video.mp4">Download</a>

One way of forcing downloads is to use a PHP function called readfile.

We have a file below called dl.php. We pass the filename to it, as well as set the path and URL.

$filename = $_GET['file'];
$filepath = "http://domain.com/download/";
$url = $filepath.$filename;
header("Content-disposition: attachment; filename=".$filename."");
header("Content-type: application/octet-stream");
readfile("".$url."");

$filename = $_GET['file']; $filepath = "http://domain.com/download/"; $url = $filepath.$filename; header("Content-disposition: attachment; filename=".$filename.""); header("Content-type: application/octet-stream"); readfile("".$url."");

Our HTML download link will look like this.

<a href="dl.php?file=video.mp4">Download</a>

<a href="dl.php?file=video.mp4">Download</a>

It’s one way of forcing a download via the PHP route.

  • 1
  • 2
  • Next Page »
  • Cloud
  • Linux
  • Git

Copyright © 2012–2021