Skip to content

farisd16/file-downloader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

File Downloader

file-downloader is a small Java CLI project for downloading chunks of a file in parallel over HTTP/HTTPS, developed for a JetBrains internship application. It supports:

  • Sequential download (threads = 1, avoids the overhead of creating threads => good for small files)
  • Parallel range download (threads > 1, good for large files)

Prerequisites

  • Java 17
  • Maven 3.9+ (or a compatible recent Maven)
  • Docker (only needed for running the local HTTP server used by tests)

How To Use

Setup

  • Compile first:
mvn compile
  • Generate test files of various sizes:
java -cp target/classes cli.TestFileGeneratorCLI ./test-files

Default generated files:

  • test-1024B.bin
  • test-65536B.bin
  • test-1048576B.bin
  • test-10485760B.bin
  • test-104857600B.bin

You can also specify custom output directory and file sizes:

java -cp target/classes cli.TestFileGeneratorCLI ./test-files <output_dir> [size_in_bytes...]

The content of the files will be pseudo random, and the used seed depends on the file name.

  • Start a local HTTP server pointing to the test files:
docker run --rm -p 8080:80 -v ./test-files:/usr/local/apache2/htdocs/ httpd:latest

Downloader CLI

Run:

java -cp target/classes cli.DownloaderCLI <url> <output_path> [threads]

Examples:

java -cp target/classes cli.DownloaderCLI http://localhost:8080/test-1048576B.bin ./downloads/file.bin
java -cp target/classes cli.DownloaderCLI http://localhost:8080/test-1048576B.bin ./downloads/file.bin 4

Unit Tests

Run tests:

mvn test

The tests expect the server to be started with Docker as specified above and default generated files in the test-files directory. The sizes and contents of the files will be checked by tests.

About

Java CLI for downloading chunks of a file in parallel over HTTP/HTTPS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages