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.0.4.tar.gz (5.0 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.0.4-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dguard_oss-0.0.4.tar.gz
  • Upload date:
  • Size: 5.0 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.0.4.tar.gz
Algorithm Hash digest
SHA256 0dfb4eb5a095782815fea6c53bdc5ed05dd46204b06f3be96202d5696df13de6
MD5 b6fed598ff6421704d151625462a7f60
BLAKE2b-256 fc3d7c81fa3725aaddf16655ce5130e09b1d6d304906e53cc52f18ee594c4dc1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dguard_oss-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.7 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.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6fdbe2e07f49998e80b1825ebb57d498e5026ebabd5d5bc972f39c51a726cdff
MD5 3ac3b884d4dfd17970f9b9828ac2bddf
BLAKE2b-256 6338500adcdbe482023e69aee36d1dbc597b663ecc8c290936d074dd87523f55

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