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

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

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>

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");

Our HTML download link will look like this.

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

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

HTML5 Download Attribute

HTML5 has a little-known attribute called download. The download attribute is often used in conjunction with the link or the <a> tag. Check the correct markup for the link tag below. Clicking on a HTML link will typically result in the browser opening up a new page, image, or a document.

In some cases, depending on your browser settings, clicking on a link will download a document, file or an image. For consistency, we can alter the behavior of the link tag by adding the download attribute. Let’s say, we want our readers to download an image, pdf, or a web page. We simply add the download attribute in the link tag.

A typical link looks like this:

<a href="page.html">link</a>

A link with the download tag would look something like this:

<a href="random-xxx.jpg" download="test.jpg">link</a>

By adding a filename in the download tag, we are specifying that we want the downloaded file to be renamed to test.png. The download attribute is currently supported on Chrome and Firefox. Safari and IE have not adapted it yet. Click on the Sample link below to see the download tag in action.