Last updated: February 5, 2025

<span aria-hidden="true" id="export-files-to-minio-a-complete-curl-guide"></span>

# Export files to MinIO: a complete cURL guide

![Tim Koschützki](/assets/images/teammates/avatar-tim-kos-1.jpg?dpl=dpl_B2d4XACVUtA1h8m6kRxZhWsda77Q)

#### Tim Koschützki

Co-founder · Berlin, Germany · Show bio

[](https://x.com/tim%5Fkos)[](https://github.com/tim-kos)

Exporting files to MinIO using cURL provides a flexible and powerful way to manage object storage operations from the command line. MinIO is a high-performance, S3-compatible object storage system that enables efficient file management and storage solutions. This guide demonstrates how to use cURL with MinIO effectively, covering installation, authentication, and automation techniques.

<span aria-hidden="true" id="introduction-to-minio-and-its-purpose"></span>

## Introduction to MinIO and its purpose

MinIO is an open-source object storage system that provides high performance and S3 compatibility. It is designed for large-scale data infrastructure and cloud-native applications. MinIO supports features like encryption, identity management, and multi-site replication, making it suitable for enterprise deployments.

<span aria-hidden="true" id="overview-of-curl-for-file-transfers"></span>

## Overview of cURL for file transfers

cURL is a versatile command-line tool for transferring data using various protocols. It supports HTTP, HTTPS, FTP, and S3, making it ideal for interacting with MinIO’s S3-compatible API. Its extensive features and wide platform support make it a reliable choice for file operations.

<span aria-hidden="true" id="setting-up-your-environment-minio-and-curl"></span>

## Setting up your environment: MinIO and cURL

<span aria-hidden="true" id="prerequisites"></span>

### Prerequisites

Install MinIO Server:

```bash
wget https://dl.min.io/server/minio/release/linux-amd64/minio
chmod +x minio

```

Install MinIO Client:

```bash
wget https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x mc

```

<span aria-hidden="true" id="version-compatibility"></span>

### Version compatibility

Tested with:

* MinIO Server RELEASE.2024-02-09T21-25-16Z
* MinIO Client mc RELEASE.2024-02-09T22-18-24Z
* Node.js SDK 7.1.3

<span aria-hidden="true" id="initial-setup"></span>

### Initial setup

Configure the MinIO client:

```bash
mc alias set myminio http://localhost:9000 YOUR-ACCESS YOUR-SECRET

```

<span aria-hidden="true" id="securing-access-to-your-minio-bucket"></span>

## Securing access to your MinIO bucket

Implement these security measures for safe file operations:

1. Enable TLS/SSL for encrypted connections.
2. Use environment variables for credentials.
3. Implement proper bucket policies.
4. Use pre-signed URLs for temporary access.

<span aria-hidden="true" id="exporting-files-to-minio-with-curl"></span>

## Exporting files to MinIO with cURL

<span aria-hidden="true" id="authentication-methods"></span>

### Authentication methods

MinIO supports three main authentication approaches:

1. MinIO Client (mc) for direct operations
2. Pre-signed URLs for temporary access
3. Official SDKs for programmatic access

<span aria-hidden="true" id="generate-pre-signed-urls"></span>

### Generate pre-signed URLs

Using MinIO Client:

```bash
mc alias set myminio http://localhost:9000 YOUR-ACCESS YOUR-SECRET
mc share upload myminio/mybucket/file.txt --expire 2h

```

Using Node.js SDK:

```javascript
const Minio = require('minio')
const client = new Minio.Client({
  endPoint: 'localhost',
  port: 9000,
  useSSL: false,
  accessKey: 'YOUR-ACCESS',
  secretKey: 'YOUR-SECRET',
})

await client.presignedPutObject('mybucket', 'file.txt', 7200)

```

<span aria-hidden="true" id="automation-example"></span>

## Automation example

```bash
#!/bin/bash
set -euo pipefail

MINIO_ALIAS="myminio"
BUCKET="mybucket"
EXPIRY="2h"

upload_file() {
    local file_path="$1"
    local file_name=$(basename "$file_path")

    echo "Generating pre-signed URL for ${file_name}..."
    presigned_url=$(mc share upload \
        "${MINIO_ALIAS}/${BUCKET}/${file_name}" \
        --expire "${EXPIRY}" --json | jq -r .url)

    echo "Uploading ${file_name}..."
    if curl -X PUT \
        --upload-file "${file_path}" \
        --fail \
        --silent \
        --show-error \
        "${presigned_url}"; then
        echo "✓ Uploaded ${file_name}"
        return 0
    else
        echo "✗ Failed to upload ${file_name}"
        return 1
    fi
}

# Setup (run once)
mc alias set "${MINIO_ALIAS}" \
    "http://localhost:9000" \
    "YOUR-ACCESS" \
    "YOUR-SECRET"

```

<span aria-hidden="true" id="advanced-techniques-handling-complex-file-structures"></span>

## Advanced techniques: handling complex file structures

<span aria-hidden="true" id="large-file-uploads"></span>

### Large file uploads

For files larger than 5GB, use multipart uploads:

```bash
mc cp --recursive local/directory myminio/mybucket/

```

<span aria-hidden="true" id="directory-synchronization"></span>

### Directory synchronization

Keep local and MinIO directories in sync:

```bash
mc mirror local/directory myminio/mybucket/

```

<span aria-hidden="true" id="common-issues--solutions"></span>

## Common issues & solutions

1. Connection refused:
   * Verify that the MinIO server is running.
   * Check firewall settings.
   * Confirm the correct endpoint and port are used.
2. Access denied:
   * Verify credentials.
   * Check the bucket policy.
   * Ensure proper permissions are set.
3. SSL/TLS errors:
   * Use the correct protocol (http or https).
   * Verify the certificate if using SSL.
   * Set the useSSL option correctly in the SDK.

<span aria-hidden="true" id="monitoring-and-logging"></span>

## Monitoring and logging

Track upload progress and maintain logs with the following command:

```bash
curl -X PUT \
  --upload-file "large-file.zip" \
  --progress-bar \
  --write-out "%{http_code}\n" \
  --output /dev/null \
  "${presigned_url}" | tee -a upload.log

```

<span aria-hidden="true" id="using-transloadit-for-optimized-minio-exports"></span>

## Using Transloadit for optimized MinIO exports

For advanced file processing and exports to MinIO, consider using[Transloadit](/index.md). Transloadit provides robust file processing capabilities and seamless integration with various storage solutions, including MinIO.

<span aria-hidden="true" id="conclusion"></span>

## Conclusion

This guide covered essential aspects of using cURL with MinIO for file exports—from installation and secure access to automation and handling complex file structures. The provided scripts and examples demonstrate secure and efficient file operations. For more sophisticated file processing needs, explore Transloadit's comprehensive file handling solutions at[transloadit.com](/index.md).

\#minio#file-management#command-line#automation#file-exporting-service

### 👩‍💻 Join 20k+ developers

Sign up for our [monthly newsletter](/newsletters.md) to receive direct links to 3 exclusive tech — and 2 product updates. No less, no more.

Your email:

Get access

## File uploading and encoding. Made simple.

Transloadit streamlines file handling for developers, trusted by brands like Coursera and The New York Times. We’re known for a reliable API, top-notch support, and a strong commitment to open source, with projects like [Uppy⁠](https://uppy.io) and [Tus⁠](https://tus.io) setting standards in file processing.

[Sign up](/c/)[Book a Demo](https://survey.typeform.com/to/kRg47Xi5)

No credit card needed · 5 GB included in the free plan

Cancel anytime
