• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

download

Windows Curl Command

January 11, 2023

If you have to download a file from the Internet on a Windows server, can certainly use the browser. But if the browser is rendering the file instead of downloading them, you may have to use the curl command which is already pre-installed on most Windows servers. Just open the command line. Here’s the the curl command to download a file.

curl.exe --output index.txt --url https://website.domain/index.txt

curl.exe --output index.txt --url https://website.domain/index.txt

Filed Under: Misc Tagged With: curl, download, server, windows

Python Web Server

May 20, 2022

Here’s a quick way to start a web server using Python (not recommended for production).

If you want to use python3, you may have to use explicitly use python3.

Check what versions you have first.

python --version
python3 --version

python --version python3 --version

Start web server using port 8080 in the current directory.

python -m http.server 8080

python -m http.server 8080

If you want an alternate directory, use this -d option.

python -m http.server 8080 -d /tmp

python -m http.server 8080 -d /tmp

It’s a great tool for quick downloads.

Filed Under: Linux Tagged With: download, python, server, web

GCP gcloud compute scp

January 31, 2022

Here’s how to download/upload files using gcloud compute scp.

Make sure you are authenticated.

gcloud auth login

gcloud auth login

How to download.

gcloud compute scp --recurse your-server:/home/username/yaml.tar.gz . \
--project your-project-id \
--zone us-central1-a \
--internal-ip

gcloud compute scp --recurse your-server:/home/username/yaml.tar.gz . \ --project your-project-id \ --zone us-central1-a \ --internal-ip

How to upload.

gcloud compute scp --recurse yaml.tar.gz your-server:/home/username/ \
--project your-project-id \
--zone us-central1-a \
--internal-ip

gcloud compute scp --recurse yaml.tar.gz your-server:/home/username/ \ --project your-project-id \ --zone us-central1-a \ --internal-ip

Filed Under: Cloud Tagged With: compute, download, files, gcloud, scp, upload

GCP Increase Download Speed for gsutil

October 2, 2019

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

Filed Under: Cloud Tagged With: download, gcp, gsutil, increase, process count, speed, thread count

Local RPM Install

March 11, 2019

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

Filed Under: Linux Tagged With: download, install, packages, yum

How To Force Downloads

July 24, 2016

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.

Filed Under: PHP Tagged With: browser, download, readfile

HTML5 Download Attribute

November 11, 2013

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 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>

<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.

Demo

Filed Under: HTML Tagged With: download, html5, link

  • Home
  • About
  • Archives

Copyright © 2023