Skip to content

ga111o/datalink_client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DataLink Client

Command line tool for file transfer

Features

  • Upload: Compress files/directories to tar.gz and upload to server
  • Download: Download and automatically extract files from server

Requirements

  • curl - for HTTP requests
  • tar - for compression/decompression

The tool will automatically check for dependencies and inform you if anything is missing.

Installation

💡 For detailed installation instructions, see INSTALL.md

Quick Install (Recommended)

Debian/Ubuntu

# Download and install .deb package
wget https://github.com/ga111o/datalink_client/releases/latest/download/dtlk_1.0.3_all.deb
sudo dpkg -i dtlk_1.0.3_all.deb

From Source

  1. Clone or download this repository
  2. Make the script executable:
    chmod +x dtlk
  3. Install system-wide (requires sudo):
    make install

During installation, you'll be prompted to configure the server:

Example installation process:

DataLink Client Installation
============================

Server Configuration:
  0) Use default server (https://datalink.ga111o.com)
  1) Configure custom server URL

Please choose an option [0]: 1
Enter your server URL (e.g., https://your-server.com): https://my-datalink.example.com

Package Building

Build your own packages:

# Build Debian package
make package-deb

# Build Arch package  
make package-arch

# Build all packages
make package-all

Usage

Upload Files

Upload one or more files or directories:

# Upload a single file
dtlk up myfile.txt

# Upload multiple files
dtlk up file1.txt file2.txt

# Upload directories
dtlk up folder1/ folder2/

# Mixed upload
dtlk up myfile.txt myfolder/ another_file.txt

The tool will:

  1. Compress all specified files/directories into a tar.gz archive
  2. Upload to the server
  3. Display an 8-digit file ID for later download

Download Files

Download files using the 8-digit ID:

# Download to current directory
dtlk down 12345678

# Download to specific directory
dtlk down 12345678 ./downloads/

# Download to non-existent directory (will be created)
dtlk down 12345678 ./new_folder/

The tool will:

  1. Download the file from the server
  2. Automatically extract the tar.gz archive
  3. Handle duplicate files by adding _dups{number} suffix if files already exist
  4. Clean up temporary files

Help

dtlk --help
dtlk help
dtlk -h

Duplicate File Handling

When downloading files, if a file or directory with the same name already exists in the destination, the tool will automatically rename the downloaded item to avoid conflicts:

  • Files: filename.txtfilename_dups1.txt, filename_dups2.txt, etc.
  • Directories: dirnamedirname_dups1, dirname_dups2, etc.
  • Files without extensions: filenamefilename_dups1, filename_dups2, etc.

The tool will inform you of any renamed files during the download process.

Configuration

Server URL Configuration

The server URL can be configured during installation using make install. You can choose between:

  • Default server: https://datalink.ga111o.com
  • Custom server URL of your choice

Manual Configuration

If you need to change the server URL after installation, you can:

  1. Edit the installed script (requires sudo):

    sudo nano /usr/local/bin/dtlk

    Find and modify the SERVER_URL variable.

  2. Reinstall with different configuration:

    make uninstall
    make install
  3. Use local copy with modified URL: Edit the dtlk script in your local directory and run it directly:

    ./dtlk up myfile.txt

Development

Testing

Run basic functionality tests:

make test

Create test files for development:

make dev-test

Clean up test files:

make dev-clean

Uninstall

Remove the installed tool:

make uninstall

Server API

The tool expects a server with the following endpoints:

  • Upload: POST /upload

    • Accepts multipart form data with file field
    • Returns JSON with id field containing numeric file ID
  • Download: GET /download/{id}

    • Returns the uploaded file
    • Should include proper headers for file download

Examples

Error Cases

The tool handles various error conditions:

  • Missing files/directories
  • Server connection issues
  • Invalid file IDs
  • Failed uploads/downloads
  • Missing dependencies

License

This project is licensed under the MIT License.

Contributing

Feel free to submit issues and enhancement requests.

About

Command-line file transfer alternative when `$ scp` is not possible

Resources

License

Stars

Watchers

Forks