S3-Compatible CLI

Command-line tool that allows you to manage your files and directories using familiar S3 commands, making it easy for users experienced with AWS S3 to work with Koneksi storage.

Complete How-To Guide

Features

  • S3-Compatible Commands: Use familiar commands like ls, cp, mv, rm, mb, and rb

  • Cross-Platform Support: Works on Linux, macOS, and Windows

  • Recursive Operations: Support for recursive directory uploads/downloads

  • Progress Indication: Visual feedback during file transfers

  • Retry Logic: Automatic retry for failed operations

  • Flexible Configuration: Support for config files and environment variables

How It Works

The CLI translates S3 concepts to Koneksi's storage model:

  • Buckets → Koneksi Directories

  • Objects → Koneksi Files

  • S3 URIs → Koneksi paths (e.g., s3://bucket/key → directory/file)

Installation

Prerequisites

  • Go 1.23 or later (for building from source)

  • Valid Koneksi API credentials (client ID and client secret)

Option 1: Download Pre-built Binary

  1. Visit the releases page herearrow-up-right.

  2. Download the appropriate binary for your platform:

    • koneksi-s3-linux-amd64 for Linux

    • koneksi-s3-darwin-amd64 for macOS (Intel)

    • koneksi-s3-darwin-arm64 for macOS (Apple Silicon)

    • koneksi-s3-windows-amd64.exe for Windows

  3. Make the binary executable (Linux/macOS):

  4. Move to a location in your PATH:

Option 2: Build from Source

  1. Clone the repository:

  2. Build the binary:

  3. Install system-wide:

Option 3: Platform-Specific Builds

Build for specific platforms:

Configuration

Configuration Methods

The CLI supports three configuration methods (in order of precedence):

  1. Environment Variables (highest priority)

  2. Configuration File

  3. Command-line Flags (for specific options)

Setting Up Configuration

Method 1: Configuration File

Create a configuration file at ~/.koneksi-s3.yaml:

Method 2: Environment Variables

Set environment variables with the KONEKSI_ prefix:

Method 3: Mixed Configuration

You can mix configuration methods. For example, store credentials in the config file but override the directory ID via environment:

Verifying Configuration

Test your configuration by listing buckets:

If configured correctly, you should see a list of your directories.

Basic Usage

Understanding S3 URI Format

The CLI uses S3-style URIs to reference remote locations:

  • s3://bucket-name/ - References a bucket (directory)

  • s3://bucket-name/path/to/object - References an object (file)

Essential Commands

List Buckets (Directories)

List Objects in a Bucket

Upload Files

Download Files

Create and Remove Buckets

Command Reference

ls - List Command

List buckets or objects in a bucket.

Syntax:

Examples:

cp - Copy Command

Copy files between local filesystem and S3, or between S3 locations.

Syntax:

Options:

  • -r, --recursive: Copy directories recursively

  • --dry-run: Show what would be copied without actually copying

Examples:

mv - Move Command

Move or rename files between local filesystem and S3, or within S3.

Syntax:

Examples:

rm - Remove Command

Remove objects from S3.

Syntax:

Options:

  • -r, --recursive: Remove objects recursively

  • --dry-run: Show what would be removed without actually removing

Examples:

mb - Make Bucket Command

Create a new bucket (directory).

Syntax:

Examples:

rb - Remove Bucket Command

Remove an empty bucket.

Syntax:

Options:

  • --force: Remove non-empty bucket

Examples:

Advanced Usage

Working with Large Files

For large file uploads, the CLI automatically handles:

  • Progress indication during transfer

  • Automatic retry on failure

  • Efficient streaming to minimize memory usage

Batch Operations

Uploading Multiple Files

Downloading Multiple Files

Scripting and Automation

Backup Script Example

Sync Script Example

Working with Different Directory IDs

Override the default directory ID for specific operations:

Performance Optimization

Parallel Uploads

Efficient Recursive Operations

Troubleshooting

Common Issues and Solutions

Authentication Errors

Problem: "Authentication failed" or "Invalid credentials"

Solutions:

  1. Verify credentials are correctly set:

  2. Ensure no extra spaces in credentials

  3. Verify credentials are active in Koneksi system

Connection Timeouts

Problem: "Request timeout" errors

Solutions:

  1. Increase timeout setting:

  2. Check network connectivity:

  3. Use retry configuration for unstable connections

File Upload Failures

Problem: Large file uploads fail

Solutions:

  1. Increase timeout for large files:

  2. Check available disk space for temporary files

  3. Verify file permissions

Directory/Bucket Not Found

Problem: "Bucket not found" errors

Solutions:

  1. List available buckets:

  2. Check bucket name spelling

  3. Verify directory ID is correct:

Debug Mode

Enable verbose output for troubleshooting:

Getting Help

  1. Built-in Help:

  2. Version Information:

Quick Reference

Essential Commands Cheatsheet

Configuration Quick Setup

Common Patterns

Tips and Best Practices

  1. Use Recursive Flags: For directory operations, always use -r flag for better performance

  2. Organize with Prefixes: Use S3-style prefixes to organize files (e.g., s3://bucket/year/month/day/)

  3. Test with Dry Run: Use --dry-run flag to preview operations before executing

  4. Script Repetitive Tasks: Create shell scripts for common operations

  5. Monitor Transfers: For large transfers, run in screen/tmux session

  6. Regular Backups: Schedule regular backups using cron jobs

  7. Secure Credentials: Never commit credentials to version control


Additional Resources

Last updated