Skip to main content

A command-line tool for interacting with MinIO.

Project description

Dguard OSS Tool: MinIO File Management CLI

Overview

The Dguard OSS Tool is a command-line interface (CLI) utility for managing file uploads and downloads with a MinIO object storage server. It simplifies the process of uploading files, downloading objects, and handling bucket operations with user-friendly defaults and optional automation features.


Features

  • Upload files to a specified or default bucket in MinIO.
  • Download objects from a specified bucket in MinIO.
  • Automatically create buckets if they do not exist (interactive or forced mode).
  • Default settings for frequently used operations.
  • Detailed help and usage examples.

Prerequisites

  1. Python: Ensure Python 3.7 or higher is installed on your system.
  2. MinIO Server: Access to a MinIO server with proper credentials.
  3. Configuration File: Create a configuration file config.json in the ~/.dguard_oss directory with the following structure:
{
    "endpoint": "xxxx:xxx",
    "access_key": "xx",
    "secret_key": "xx",
    "secure": false
}

Installation

pip install dguard_oss

Usage

The CLI offers the following commands:

General Syntax

oss <command> [arguments] [options]

Commands

1. Upload Files

Uploads a file to a bucket in MinIO. If the bucket does not exist, the tool can create it interactively or automatically with the -y option.

Syntax
oss upload <file_path> [bucket] [object_name] [-y] [--id=<config_id>]
Parameters
  • file_path (required): Path to the file to be uploaded.
  • bucket (optional): Target bucket name. Defaults to temp.
  • object_name (optional): Name for the object in the bucket. Defaults to the file name.
  • -y (optional): Automatically creates the bucket if it does not exist.
  • --id (optional): Configuration ID to use (default: config).
Examples
  • Upload a file to the default bucket:

    oss upload ./example.txt
    
  • Upload a file to a specific bucket with the same file name:

    oss upload ./example.txt my_bucket
    
  • Upload a file to a specific bucket with a custom object name:

    oss upload ./example.txt my_bucket custom_name.txt
    
  • Upload a file and force bucket creation:

    oss upload ./example.txt my_bucket -y
    

2. Download Files

Downloads a file from a bucket in MinIO to the local system.

Syntax
oss download [bucket] <object_name> <save_path> [--id=<config_id>]
Parameters
  • bucket (optional): Source bucket name. Defaults to temp.
  • object_name (required): Name of the object in the bucket to download.
  • save_path (required): Path to save the downloaded file locally.
  • --id (optional): Configuration ID to use (default: config).
Examples
  • Download a file from the default bucket:

    oss download example.txt ./local_example.txt
    
  • Download a file from a specific bucket:

    oss download my_bucket example.txt ./local_example.txt
    

3. Help

Displays detailed help information about the CLI.

Syntax
oss help
Example
oss help

Workflow Details

  1. Upload Workflow:

    • If the target bucket does not exist, the tool will prompt the user to create it.
    • The -y option skips prompts and automatically creates the bucket.
    • The object name defaults to the file name if not specified.
  2. Download Workflow:

    • Ensures the specified object and bucket exist before attempting to download.
    • Saves the object locally at the specified save_path.

Error Handling

  • Invalid arguments or missing required parameters will result in an error message and display the help information.
  • Bucket or object access errors are captured and reported with detailed messages.

Examples

Upload Example

  1. Uploading a file to the default bucket:

    oss upload ./data.txt
    
  2. Uploading with automatic bucket creation:

    oss upload ./data.txt new_bucket -y
    

Download Example

  1. Downloading a file from the default bucket:

    oss download data.txt ./local_data.txt
    
  2. Downloading from a specific bucket:

    oss download my_bucket data.txt ./local_data.txt
    

Help

oss help

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dguard_oss-0.1.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dguard_oss-0.1.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file dguard_oss-0.1.1.tar.gz.

File metadata

  • Download URL: dguard_oss-0.1.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.7

File hashes

Hashes for dguard_oss-0.1.1.tar.gz
Algorithm Hash digest
SHA256 854a692876a573c8d6aaff37ac2db3d4ae4d58d8e678b3f6bfc7a327f6af4e77
MD5 742fb3ababf6df535e696b07068523c3
BLAKE2b-256 9b07b0831487edb2300ec68a800d0cf6dacca6ee42bd7cd591b5a271a8896466

See more details on using hashes here.

File details

Details for the file dguard_oss-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: dguard_oss-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.7

File hashes

Hashes for dguard_oss-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 494924580e1de164aa2bb9c6e14d47c3432ae50664625a7c51dd702d261d0d68
MD5 04eb35fd63b57242f31aa7ebb16d9526
BLAKE2b-256 8033951de35b3cdc57f34589c59011a2455be0d077bd55d50acd2835d8d2a9d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page