PHPackages                             dhananjay-vaidya/s3-connector - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. dhananjay-vaidya/s3-connector

ActiveLibrary[File &amp; Storage](/categories/file-storage)

dhananjay-vaidya/s3-connector
=============================

A lightweight Laravel service for easy integration with the S3 Connector API. Provides simple interface to interact with S3 storage through the S3 Connector API without direct AWS SDK integration.

1.1.1(9mo ago)04MITPHPPHP ^8.0

Since Aug 12Pushed 9mo agoCompare

[ Source](https://github.com/dhananjayvaidya/s3-connector-composer-package)[ Packagist](https://packagist.org/packages/dhananjay-vaidya/s3-connector)[ Docs](https://github.com/dhananjay-vaidya/s3-connector)[ RSS](/packages/dhananjay-vaidya-s3-connector/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (7)Versions (4)Used By (0)

S3 Connector
============

[](#s3-connector)

A lightweight Laravel package for easy integration with the S3 Connector API. This package provides a simple interface to interact with S3 storage through the S3 Connector API without the need for direct AWS SDK integration.

[![Latest Version on Packagist](https://camo.githubusercontent.com/4a600c0a7629255ffa44d1336b54f541a161992c88aa8b51fb29490a329da48c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6468616e616e6a61792d7661696479612f73332d636f6e6e6563746f722e737667)](https://packagist.org/packages/dhananjay-vaidya/s3-connector)[![Total Downloads on Packagist](https://camo.githubusercontent.com/364c076e3a748d331e01bdbe39870ebb0fe581e0d715624d937dd3651440c098/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6468616e616e6a61792d7661696479612f73332d636f6e6e6563746f722e737667)](https://packagist.org/packages/dhananjay-vaidya/s3-connector)[![License](https://camo.githubusercontent.com/a551a421b0dbe25803e441334552449f7de1eab0d3d12e59d3d1418ec700024e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6468616e616e6a61792d7661696479612f73332d636f6e6e6563746f722e737667)](https://packagist.org/packages/dhananjay-vaidya/s3-connector)

Features
--------

[](#features)

- 🚀 **Simple Integration** - Easy to add to any Laravel project via Composer
- 🔐 **API Key Authentication** - Secure access using API keys
- 📁 **Complete S3 Operations** - Upload, download, delete, list, copy, and more
- 🔗 **Presigned URLs** - Generate temporary access URLs for files
- 📊 **Health Monitoring** - Check API status and configuration
- 🧹 **Cleanup Tools** - Manage temporary files and storage
- 📝 **Comprehensive Logging** - Track all API requests and responses
- ⚡ **Configurable** - Customize timeouts, logging, and other settings

Installation
------------

[](#installation)

### Via Composer (Recommended)

[](#via-composer-recommended)

```
composer require dhananjay-vaidya/s3-connector
```

### Manual Installation

[](#manual-installation)

If you prefer manual installation:

```
# Download the package
git clone https://github.com/dhananjay-vaidya/s3-connector.git

# Copy files to your project
cp -r s3-connector/src/* app/Services/
cp s3-connector/config/s3-connector.php config/
```

Configuration
-------------

[](#configuration)

### 1. Publish Configuration (Optional)

[](#1-publish-configuration-optional)

```
php artisan vendor:publish --tag=s3-connector-config
```

### 2. Add Environment Variables

[](#2-add-environment-variables)

Add these to your `.env` file:

```
# Required: Your S3 Connector API key
S3_CONNECTOR_API_KEY=sk_your_api_key_here

# Optional: Base URL of your S3 Connector API
S3_CONNECTOR_BASE_URL=http://localhost:8000/api

# Optional: Request timeout in seconds
S3_CONNECTOR_TIMEOUT=30

# Optional: Enable/disable logging
S3_CONNECTOR_ENABLE_LOGGING=true

# Optional: Default file visibility
S3_CONNECTOR_DEFAULT_VISIBILITY=private

# Optional: Default presigned URL expiration
S3_CONNECTOR_PRESIGNED_EXPIRATION=3600
```

### 3. Service Provider (Auto-registered)

[](#3-service-provider-auto-registered)

The package automatically registers the service provider. If you need manual registration, add this to `config/app.php`:

```
'providers' => [
    // ... other providers
    DhananjayVaidya\S3Connector\S3ConnectorServiceProvider::class,
],
```

Usage
-----

[](#usage)

### Using Dependency Injection

[](#using-dependency-injection)

```
use DhananjayVaidya\S3Connector\S3ConnectorService;

class FileController extends Controller
{
    protected $s3Service;

    public function __construct(S3ConnectorService $s3Service)
    {
        $this->s3Service = $s3Service;
    }

    public function upload(Request $request)
    {
        $file = $request->file('file');
        $result = $this->s3Service->upload($file, 'uploads/documents/');

        if ($result['success']) {
            return response()->json([
                'message' => 'File uploaded successfully',
                'data' => $result['data']
            ]);
        }

        return response()->json([
            'error' => $result['error']
        ], 400);
    }
}
```

### Using the Facade

[](#using-the-facade)

```
use DhananjayVaidya\S3Connector\Facades\S3Connector;

// Upload a file
$result = S3Connector::upload($file, 'uploads/');

// Download a file
$result = S3Connector::download('uploads/file.pdf');

// List files
$files = S3Connector::list('uploads/', 100);

// Get file metadata
$metadata = S3Connector::metadata('uploads/file.pdf');
```

### Using the Service Container

[](#using-the-service-container)

```
$s3Service = app('s3-connector');
$result = $s3Service->upload($file, 'uploads/');
```

Available Methods
-----------------

[](#available-methods)

### File Operations

[](#file-operations)

MethodDescriptionParameters`upload()`Upload a file to S3`$file`, `$path`, `$metadata`, `$visibility``download()`Download a file from S3`$key`, `$localPath``delete()`Delete a file from S3`$key``list()`List files in S3 bucket`$prefix`, `$maxKeys``metadata()`Get file metadata`$key``exists()`Check if file exists`$key``copy()`Copy a file in S3`$sourceKey`, `$destinationKey`, `$metadata``presignedUrl()`Generate presigned URL`$key`, `$expiresIn`, `$operation`### System Operations

[](#system-operations)

MethodDescriptionParameters`health()`Check API healthNone`configCheck()`Check S3 configurationNone`bucketInfo()`Get bucket informationNone`cleanupTemp()`Clean up temporary filesNone### Utility Methods

[](#utility-methods)

MethodDescriptionParameters`testConnection()`Test API connectionNone`getServiceInfo()`Get service informationNone`validateApiKey()`Validate API key formatNoneExamples
--------

[](#examples)

### Upload with Metadata

[](#upload-with-metadata)

```
$result = $s3Service->upload(
    $request->file('document'),
    'documents/invoices/',
    [
        'invoice_number' => 'INV-001',
        'customer_id' => '12345',
        'uploaded_by' => auth()->id()
    ],
    'private'
);
```

### Download and Save Locally

[](#download-and-save-locally)

```
$result = $s3Service->download(
    'documents/invoices/invoice.pdf',
    'local/invoices/invoice.pdf'
);

if ($result['success']) {
    echo "File saved to: " . $result['local_path'];
}
```

### Generate Presigned URL

[](#generate-presigned-url)

```
$result = $s3Service->presignedUrl(
    'documents/report.pdf',
    7200, // 2 hours
    'getObject'
);

if ($result['success']) {
    $downloadUrl = $result['data']['presigned_url'];
    // Use $downloadUrl for temporary file access
}
```

### List Files with Pagination

[](#list-files-with-pagination)

```
$result = $s3Service->list('uploads/images/', 50);

if ($result['success']) {
    foreach ($result['data']['files'] as $file) {
        echo "File: " . $file['key'] . " (Size: " . $file['size'] . ")\n";
    }
}
```

### Health Check

[](#health-check)

```
$health = $s3Service->health();

if ($health['success']) {
    echo "S3 Connector is healthy!\n";
    echo "Bucket status: " . $health['data']['bucket_status'] . "\n";
} else {
    echo "Health check failed: " . $health['error'] . "\n";
}
```

Response Format
---------------

[](#response-format)

All methods return a consistent response format:

```
// Success response
[
    'success' => true,
    'data' => [...],
    'message' => 'Operation completed successfully',
    'status_code' => 200
]

// Error response
[
    'success' => false,
    'error' => 'Error message',
    'status_code' => 400
]
```

### Example Error Handling

[](#example-error-handling)

```
$result = $s3Service->upload($file, 'uploads/');

if (!$result['success']) {
    Log::error('S3 upload failed', [
        'error' => $result['error'],
        'status_code' => $result['status_code']
    ]);

    return response()->json([
        'error' => 'Upload failed: ' . $result['error']
    ], 400);
}

// Handle success
return response()->json([
    'message' => 'File uploaded successfully',
    'file_url' => $result['data']['url']
]);
```

Testing
-------

[](#testing)

### Run Tests

[](#run-tests)

```
composer test
```

### Test Configuration

[](#test-configuration)

The package includes PHPUnit configuration and test suite setup. Tests use Orchestra Testbench for Laravel package testing.

Logging
-------

[](#logging)

The service automatically logs all API requests and responses when logging is enabled:

```
// In your .env file
S3_CONNECTOR_ENABLE_LOGGING=true
```

Log entries include:

- Request method and URL
- Response status and size
- Error details (if any)
- File operation details

Troubleshooting
---------------

[](#troubleshooting)

### Common Issues

[](#common-issues)

1. **API Key Error**

    ```
    S3 Connector API key is required. Please set S3_CONNECTOR_API_KEY in your .env file.

    ```

    **Solution**: Add your API key to the `.env` file
2. **Connection Timeout**

    ```
    Request failed: cURL error 28: Operation timed out

    ```

    **Solution**: Increase timeout in configuration or check network connectivity
3. **Authentication Failed**

    ```
    Unauthorized: Invalid API key

    ```

    **Solution**: Verify your API key is correct and has proper permissions
4. **File Not Found**

    ```
    Download failed: File not found

    ```

    **Solution**: Check the file key/path exists in your S3 bucket

### Debug Mode

[](#debug-mode)

Enable detailed logging for debugging:

```
$s3Service->setLogging(true);
$s3Service->setTimeout(60); // Increase timeout for large files
```

Security Considerations
-----------------------

[](#security-considerations)

- **API Key Security**: Keep your API key secure and never commit it to version control
- **File Permissions**: Use appropriate file visibility settings for your use case
- **Input Validation**: Always validate file inputs before uploading
- **Rate Limiting**: Be aware of API rate limits for your S3 Connector instance

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

### Development Setup

[](#development-setup)

```
# Clone the repository
git clone https://github.com/dhananjay-vaidya/s3-connector.git

# Install dependencies
composer install

# Run tests
composer test

# Run PHPStan analysis
composer analyse
```

Support
-------

[](#support)

For issues and questions:

1. Check the [documentation](https://github.com/dhananjay-vaidya/s3-connector/blob/main/README.md)
2. Review the error logs
3. Verify your configuration settings
4. Test the connection using the `testConnection()` method
5. [Create an issue](https://github.com/dhananjay-vaidya/s3-connector/issues) on GitHub

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

Changelog
---------

[](#changelog)

Please see [CHANGELOG.md](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- **Dhananjay Vaidya** - *Initial work* - [dhananjay-vaidya](https://github.com/dhananjay-vaidya)

---

**S3 Connector** makes S3 storage integration simple, secure, and scalable for any Laravel project. 🚀

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance58

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

274d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3250936?v=4)[Dhananjay Vaidya](/maintainers/dhananjayvaidya)[@dhananjayvaidya](https://github.com/dhananjayvaidya)

---

Top Contributors

[![dhananjayvaidya](https://avatars.githubusercontent.com/u/3250936?v=4)](https://github.com/dhananjayvaidya "dhananjayvaidya (3 commits)")

---

Tags

apilaravels3awsservicestorageconnectorfile management

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dhananjay-vaidya-s3-connector/health.svg)

```
[![Health](https://phpackages.com/badges/dhananjay-vaidya-s3-connector/health.svg)](https://phpackages.com/packages/dhananjay-vaidya-s3-connector)
```

###  Alternatives

[codesleeve/laravel-stapler

Easy file upload management for the Laravel Framework.

558413.9k11](/packages/codesleeve-laravel-stapler)[publiux/laravelcdn

Content Delivery Network (CDN) Package for Laravel

155230.4k](/packages/publiux-laravelcdn)[zgldh/laravel-upload-manager

Upload, validate, storage, manage by API for Laravel 5/6/7/8/9

795.5k2](/packages/zgldh-laravel-upload-manager)[juhasev/laravelcdn

Content Delivery Network (CDN) Package for Laravel

1820.4k](/packages/juhasev-laravelcdn)[unisharp/s3-presigned

An AWS S3 package for pre-signed upload purpose in Laravel and PHP.

151.8k](/packages/unisharp-s3-presigned)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
