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.0.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.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dguard_oss-0.1.0.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.1.0.tar.gz
Algorithm Hash digest
SHA256 bb388694c0929728d32c0c8967d4765b3ee3d3f01e58508c72c4a8b0e50269d5
MD5 ef4f1669b546942317c2cb25684233b9
BLAKE2b-256 be9aac2d7a01437f4e59f35861c22b636ca96f6fa526d928ce5277dd0d9b65e0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dguard_oss-0.1.0-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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 664dac1fdacae69dfbd8d1462b8e4a7cba7101068107c2216f92b89d2465ad4a
MD5 8567335010e3a30b04cda9acbf15b6a5
BLAKE2b-256 a5430981abbebe72f469fa9027662a9347c6dbeaa05d395dea634676ec880e71

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