Skip to content

Commit

Permalink
Add guide: download files with curl (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
devadvance committed Apr 16, 2023
1 parent 47b91bc commit 33a513b
Show file tree
Hide file tree
Showing 15 changed files with 650 additions and 16 deletions.
28 changes: 16 additions & 12 deletions Gemfile.lock
Expand Up @@ -4,17 +4,19 @@ GEM
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
colorator (1.1.0)
concurrent-ruby (1.1.10)
concurrent-ruby (1.2.2)
em-websocket (0.5.3)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
eventmachine (1.2.7)
ffi (1.15.5)
forwardable-extended (2.6.0)
google-protobuf (3.22.2-arm64-darwin)
google-protobuf (3.22.2-x86_64-linux)
http_parser.rb (0.8.0)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
jekyll (4.3.1)
jekyll (4.3.2)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
Expand All @@ -32,8 +34,8 @@ GEM
webrick (~> 1.7)
jekyll-feed (0.17.0)
jekyll (>= 3.7, < 5.0)
jekyll-sass-converter (2.2.0)
sassc (> 2.0.1, < 3.0)
jekyll-sass-converter (3.0.0)
sass-embedded (~> 1.54)
jekyll-sitemap (1.4.0)
jekyll (>= 3.7, < 5.0)
jekyll-watch (2.2.1)
Expand All @@ -42,26 +44,28 @@ GEM
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
liquid (4.0.3)
listen (3.7.1)
liquid (4.0.4)
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.4.0)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (5.0.0)
public_suffix (5.0.1)
rake (13.0.6)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.2.5)
rouge (4.0.0)
rouge (4.1.0)
safe_yaml (1.0.5)
sassc (2.4.0)
ffi (~> 1.9)
sass-embedded (1.59.3)
google-protobuf (~> 3.21)
rake (>= 10.0.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
unicode-display_width (2.3.0)
webrick (1.7.0)
unicode-display_width (2.4.2)
webrick (1.8.1)

PLATFORMS
arm64-darwin-21
Expand Down
20 changes: 20 additions & 0 deletions _data/guides/guide-index.yml
Expand Up @@ -79,3 +79,23 @@
id: /id/guides/basic-web-server-macos-linux
te: /te/guides/basic-web-server-macos-linux
fr: /fr/guides/basic-web-server-macos-linux

- id: curl-download-files
title:
en: How to download files with curl
es: Cómo descargar archivos con curl
ar: كيفية تنزيل الملفات باستخدام الـ curl
pt-BR: Como baixar arquivos com curl
hi: curl के साथ फाइलें कैसे डाउनलोड करें
id: Cara mengunduh file dengan curl
te: curl తో ఫైళ్ళు డౌన్‌లోడ్ చేయడం ఎలా
fr: Comment télécharger des fichiers avec curl
link:
en: /guides/curl-download-files
es: /es/guides/curl-download-files
ar: /ar/guides/curl-download-files
pt-BR: /pt-BR/guides/curl-download-files
hi: /hi/guides/curl-download-files
id: /id/guides/curl-download-files
te: /te/guides/curl-download-files
fr: /fr/guides/curl-download-files
76 changes: 76 additions & 0 deletions guides/download-with-curl.md
@@ -0,0 +1,76 @@
---
layout: guide-layout
title: How to download files with curl
excerpt: How to download files with curl
permalink: /guides/curl-download-files
permalink_without_prefix: /guides/curl-download-files
lang: en
---

**Table of contents**

* TOC
{:toc}

## Introduction

This guide is intended to teach you the basic ways to download files using [curl](https://github.com/curl/curl). As you follow these instructions, keep in mind that your computer's files and folders likely will be different from the samples. If you already have a lot of experience with the terminal, check out [the commands on the homepage for quick reference material](/).

## Prerequisites

In order follow this guide, you will need:

* Access to a Unix terminal on any Linux or a macOS environment.
* To know how to open a terminal window. If you are not sure, visit the instructions for [macOS](open-terminal-macos) or Linux (coming soon).
* A file you want to download. We are using `https://terminalcheatsheet.com/sample-file.jpg` as an example in this guide.
* The curl utility installed on your computer. Most macOS and Linux computers have it preinstalled. If not, you'll need to review the technical instructions [on the curl installation website](https://curl.haxx.se/docs/install.html){:target="_blank" rel="noopener"}.

## Downloading a file

Start by opening your terminal.

`curl` is a "command-line tool for transferring data specified with URL syntax". This means it can download files from URLs.

For example, [https://terminalcheatsheet.com/sample-file.jpg](https://terminalcheatsheet.com/sample-file.jpg){:target="_blank" rel="noopener"} returns an image file that we can download with curl.

### Save with the filename from the URL

If we want to download the file and save it with the same name, we can use this command:

```
curl --remote-name [URL]
```

`[URL]` is the URL we want to download the file from. `--remote-name` instructs curl to use the name from the URL as the name for the file on the computer.

We can use this shorter command to do the same:

```
curl -O [URL]
```

`-O` is a short way of writing `--remote-name` from the previous command.

### Save with a different filename

If we want to download the file and save it with a different name, we can use this command instead:

```
curl --output [FILENAME] [URL]
```

* `[URL]` - We tell `curl` the URL to download.
* `--output [FILENAME]` - We tell `curl` where to save the file.

We can use this shorter command to do the same:

```
curl -o [FILENAME] [URL]
```

* `[URL]` - We tell `curl` the URL to download.
* `-o [FILENAME]` - We tell `curl` where to save the file.

## Wrapping up

Now you know a bit about using `curl` to download files from a URL.
80 changes: 80 additions & 0 deletions i18n/ar/guides/download-with-curl.md
@@ -0,0 +1,80 @@
---
layout: guide-layout
title: كيفية تنزيل الملفات باستخدام الـ curl
excerpt: كيفية تنزيل الملفات باستخدام الـ curl
permalink: /ar/guides/curl-download-files
permalink_without_prefix: /guides/curl-download-files
lang: ar
direction: rtl
---

**جدول المحتويات**

* TOC
{:toc}

## مقدمة

يهدف هذا الدليل إلى تعليمك الطرق الأساسية لتنزيل الملفات باستخدام [curl](https://github.com/curl/curl). أثناء اتباع هذه التعليمات، ضع في اعتبارك أن ملفات ومجلدات الكمبيوتر الخاصة بك على الأرجح ستكون مختلفة عن النماذج. إذا كنت تمتلك الكثير من الخبرة بالفعل مع المحطة، تحقق من [الأوامر الموجودة على الصفحة الرئيسية للحصول على مواد مرجعية سريعة](/ar/).

## المتطلبات الأولية

لاتباع هذا الدليل، ستحتاج إلى:

* الوصول إلى نافذة المحطة على أي نظام تشغيل لينكس أو macOS.
* معرفة كيفية فتح نافذة المحطة. إذا لم تكن متأكدًا، قم بزيارة التعليمات لـ [macOS](open-terminal-macos) أو Linux (قريبًا).
* ملف تريد تنزيله. نستخدم `https://terminalcheatsheet.com/sample-file.jpg` كمثال في هذا الدليل.
* تثبيت أداة curl على جهاز الكمبيوتر الخاص بك. يأتي معظم أجهزة الكمبيوتر بنظام macOS و Linux مزودة بها مسبقًا. إذا لم يكن الأمر كذلك، فستحتاج إلى مراجعة التعليمات الفنية [على موقع تثبيت curl](https://curl.haxx.se/docs/install.html){:target="_blank" rel="noopener"}.

## تنزيل ملف

ابدأ بفتح المحطة.

تعتبر `curl` "أداة سطر الأوامر لنقل البيانات المحددة بصيغة عنوان URL". وهذا يعني أنه يمكن تنزيل الملفات من عناوين URL.

على سبيل المثال، [https://terminalcheatsheet.com/sample-file.jpg](https://terminalcheatsheet.com/sample-file.jpg){:target="_blank" rel="noopener"} يعود بملف صورة يمكننا تنزيله باستخدام curl.

### حفظ بنفس اسم الملف من الرابط

إذا كنا نريد تنزيل الملف وحفظه بنفس الاسم، يمكننا استخدام هذا الأمر:

```
curl --remote-name [URL]
```


`[URL]` هو الرابط الذي نريد تنزيل الملف منه. يأمر `--remote-name` بأن يستخدم اسم الملف من الرابط كاسم للملف على الكمبيوتر.

يمكننا استخدام هذا الأمر الأقصر للقيام بنفس الشيء:

```
curl -O [URL]
```


`-O` هو الطريقة المختصرة لكتابة `--remote-name` من الأمر السابق.

### حفظ باسم ملف مختلف

إذا كنا نريد تنزيل الملف وحفظه باسم مختلف، يمكننا استخدام هذا الأمر بدلاً من ذلك:

```
curl --output [FILENAME] [URL]
```


* `[URL]` - نخبر `curl` بالرابط الذي نريد تنزيله.
* `--output [FILENAME]` - نخبر `curl` بمكان حفظ الملف.

يمكننا استخدام هذا الأمر الأقصر للقيام بنفس الشيء:

```
curl -o [FILENAME] [URL]
```

* `[URL]` - نخبر `curl` بالرابط الذي نريد تنزيله.
* `-o [FILENAME]` - نخبر `curl` بمكان حفظ الملف.

## الختام

الآن أنت تعرف قليلاً عن استخدام `curl` لتنزيل الملفات من رابط URL.
75 changes: 75 additions & 0 deletions i18n/es/guides/download-with-curl.md
@@ -0,0 +1,75 @@
---
layout: guide-layout
title: Cómo descargar archivos con curl
excerpt: Cómo descargar archivos con curl
permalink: /es/guides/curl-download-files
permalink_without_prefix: /guides/curl-download-files
lang: es
---

**Índice del artículo**

* TOC
{:toc}

## Introducción
Esta guía tiene como objetivo enseñarte las formas básicas de descargar archivos utilizando [curl](https://github.com/curl/curl). Mientras sigues estas instrucciones, ten en cuenta que los archivos y carpetas de tu computadora probablemente serán diferentes a los ejemplos. Si ya tienes mucha experiencia con el terminal, consulta [los comandos en la página de inicio para obtener material de referencia rápida](/es/).

## Prerrequisitos

Para seguir esta guía, necesitarás:

* Acceso a un terminal en cualquier entorno Linux o macOS.
* Saber abrir una ventana de terminal. Si no estás seguro, consulta las instrucciones para [macOS](open-terminal-macos) o Linux (próximamente).
* Un archivo que quieras descargar. Estamos utilizando `https://terminalcheatsheet.com/sample-file.jpg` como ejemplo en esta guía.
* La utilidad curl instalada en tu computadora. La mayoría de las computadoras macOS y Linux la tienen preinstalada. Si no es así, deberás revisar las instrucciones técnicas [en el sitio web de instalación de curl](https://curl.haxx.se/docs/install.html){:target="_blank" rel="noopener"}.

## Descargando un archivo

Comienza abriendo tu terminal.

`curl` es una "herramienta de línea de comandos para transferir datos especificados con la sintaxis URL". Esto significa que puede descargar archivos desde URLs.

Por ejemplo, [https://terminalcheatsheet.com/sample-file.jpg](https://terminalcheatsheet.com/sample-file.jpg){:target="_blank" rel="noopener"} devuelve un archivo de imagen que podemos descargar con curl.

### Guardar con el nombre de archivo de la URL

Si queremos descargar el archivo y guardarlo con el mismo nombre, podemos usar este comando:

```
curl --remote-name [URL]
```

`[URL]` es la URL desde la que queremos descargar el archivo. `--remote-name` indica a curl que use el nombre de la URL como el nombre del archivo en la computadora.

Podemos usar este comando más corto para hacer lo mismo:

```
curl -O [URL]
```

`-O` es una forma abreviada de escribir `--remote-name` del comando anterior.

### Guardar con un nombre de archivo diferente

Si queremos descargar el archivo y guardarlo con un nombre diferente, podemos usar este comando en su lugar:

```
curl --output [FILENAME] [URL]
```

* `[URL]` - Le indicamos a `curl` la URL para descargar.
* `--output [FILENAME]` - Le indicamos a `curl` dónde guardar el archivo.

Podemos usar este comando más corto para hacer lo mismo:

```
curl -o [FILENAME] [URL]
```

* `[URL]` - Le indicamos a `curl` la URL para descargar.
* `-o [FILENAME]` - Le indicamos a `curl` dónde guardar el archivo.

## Conclusión

Ahora ya sabes un poco sobre cómo usar `curl` para descargar archivos desde una URL.
2 changes: 1 addition & 1 deletion i18n/fr/guides/basic-web-server-macos-linux.md
Expand Up @@ -14,7 +14,7 @@ lang: fr

## Introduction

Si vous travaillez sur des pages web ou d'autres contenus web, vous pouvez avoir besoin d'une façon simple et rapide de lancer un serveur web basique. Ce guide va vous apprendre une commande Python pour lancer un serveur web basique sur votre machine. En suivant ces instructions, gardez à l'esprit que vos fichiers et dossiers de votre machine seront probablement différents des exemples. Si vous maitrisez déjà le terminal, allez voir [les commandes de la page d'accueil pour de l'aide](/)
Si vous travaillez sur des pages web ou d'autres contenus web, vous pouvez avoir besoin d'une façon simple et rapide de lancer un serveur web basique. Ce guide va vous apprendre une commande Python pour lancer un serveur web basique sur votre machine. En suivant ces instructions, gardez à l'esprit que vos fichiers et dossiers de votre machine seront probablement différents des exemples. Si vous maitrisez déjà le terminal, allez voir [les commandes de la page d'accueil pour de l'aide](/fr/)

## Prérequis

Expand Down
2 changes: 1 addition & 1 deletion i18n/fr/guides/curl-rest-api.md
Expand Up @@ -14,7 +14,7 @@ lang: fr

## Introduction

Ce guide est destiné à vous apprendre les bases de l'interaction avec une API REST en utilisant [curl](https://github.com/curl/curl). En suivant ces instructions, n'oubliez pas que les fichiers et dossiers de votre ordinateur seront probablement différents de ceux des exemples. Si vous avez déjà beaucoup d'expérience avec le terminal sur macOS, consultez [les commandes sur la page d'accueil pour des référence rapidel](/).
Ce guide est destiné à vous apprendre les bases de l'interaction avec une API REST en utilisant [curl](https://github.com/curl/curl). En suivant ces instructions, n'oubliez pas que les fichiers et dossiers de votre ordinateur seront probablement différents de ceux des exemples. Si vous avez déjà beaucoup d'expérience avec le terminal sur macOS, consultez [les commandes sur la page d'accueil pour des référence rapidel](/fr/).

## Conditions préalables

Expand Down

0 comments on commit 33a513b

Please sign in to comment.