PHPackages                             jeansouzak/duf - 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. jeansouzak/duf

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

jeansouzak/duf
==============

DUF (Download and Upload Files) - Fetch URL file, download and upload to a service

0.0.13(2y ago)109873MITPHP

Since May 12Pushed 2y ago1 watchersCompare

[ Source](https://github.com/jeansouzak/duf)[ Packagist](https://packagist.org/packages/jeansouzak/duf)[ RSS](/packages/jeansouzak-duf/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (2)Versions (15)Used By (0)

Duf - PHP Download and Upload Files
===================================

[](#duf---php-download-and-upload-files)

Duf is a PHP package to download files from web/local and upload to other servers (Google Cloud Storage).

 [![](.github/duf.png?raw=true)](.github/duf.png?raw=true)

- First package version: Download resources from web and local to upload to Google Cloud Storage ☑
- Second package version: Create Duffer adapter to upload to Amazon S3 ☐

Installing Duf
--------------

[](#installing-duf)

The recommended way to install Duf is through [Composer](https://getcomposer.org/).

```
composer require jeansouzak/duf
```

How it works:
-------------

[](#how-it-works)

```
use JeanSouzaK\Duf\Duff;
use JeanSouzaK\Duf\Prepare\WebResource;

$duf = Duff::getInstance(Duff::GOOGLE_CLOUD_STORAGE, [
    'project_id' => 'storage-test-227305',
    'key_path' => '/home/env/storage-test-227305-8472347a39489.json'
]);

// - Chaining example -
$uploadResults = $duf->prepare([
    new WebResource('teste.png', 'https://dummyimage.com/600x400/000/fff')
])->download()->addBucket('meubucket666')->upload();

// - Step-by-step example -
//Prepare object name and url
$duf->prepare([
    new WebResource('object_one.png', 'https://dummyimage.com/600x400/000/fff'),
    new WebResource('object_two.png', 'https://dummyimage.com/300x200/000/fff'),
    new WebResource('object_three.png', 'https://dummyimage.com/100x100/000/fff')
]);

//Make download prepared files
$duf->download();

//Add google cloud storage bucket name
$duf->addBucket('meubucket666');

//Upload downloaded files to bucket and get results
$uploadResults = $duf->upload();

// Iterate results and get result path
echo '';
foreach ($uploadResults as $uploadResult) {
    print_r($uploadResult);
    echo (string)$uploadResult.'';
}
```

Duf will help you if you desire upload a local file as well:
------------------------------------------------------------

[](#duf-will-help-you-if-you-desire-upload-a-local-file-as-well)

```
use JeanSouzaK\Duf\Duff;
use JeanSouzaK\Duf\Prepare\LocalResource;
use JeanSouzaK\Duf\Prepare\WebResource;

//Call factory to get google cloud storage duffer
$duf = Duff::getInstance(Duff::GOOGLE_CLOUD_STORAGE, [
    'project_id' => 'storage-test-227305',
    'key_path' => '/home/env/storage-test-227305-8472347a39489.json'
]);

//Uploading from local file target
$duf->prepare([
    new LocalResource('imagem', '/home/test/images/test.jpg')
]);

//You can mix local and remote target file
$duf->prepare([
    new LocalResource('imagem', '/home/test/images/test.jpg'),
    new WebResource('teste.png', 'https://dummyimage.com/600x400/000/fff')
]);

//Make download prepared files
$duf->download();

//Add google cloud storage bucket name
$duf->addBucket('meubucket666');

//Upload downloaded files to bucket and get results
$fileResults = $duf->upload();
```

Using filters:
--------------

[](#using-filters)

```
use JeanSouzaK\Duf\Duff;
use JeanSouzaK\Duf\Prepare\WebResource;
use JeanSouzaK\Duf\Filter\WebFileSizeFilter;
use JeanSouzaK\Duf\Filter\WebFileExtensionFilter;
use JeanSouzaK\Duf\Filter\LocalFileSizeFilter;
use JeanSouzaK\Duf\Filter\LocalFileExtensionFilter;

//Call Factory to get google cloud storage duffer instance
$duf = Duff::getInstance(Duff::GOOGLE_CLOUD_STORAGE, [
    'project_id' => 'storage-test-227305',
    'key_path' => '/home/env/storage-test-227305-8472347a39489.json'
]);

//[WEB Filter] Configure a maximum file size to bind in a resource
$webPngSizeFilter = new WebFileSizeFilter(2, WebFileSizeFilter::MB);
//[WEB Filter] Configure alloweed extensions to bind in a resource
$webAllowedExtensionFilter = new WebFileExtensionFilter([
    WebFileExtensionFilter::JPEG,
    WebFileExtensionFilter::PNG
]);

$localJpgSizeFilter = new LocalFileSizeFilter(1, 'M');
$localAllowedExtensionFilter = new LocalFileExtensionFilter([
    'json',
    'doc',
    'docx'
]);

//Prepare object name, url and filters
$duf->prepare([
    new WebResource('object_one.png', 'https://dummyimage.com/600x400/000/fff', [$webPngSizeFilter]),
    new WebResource('object_two.png', 'https://dummyimage.com/600x400/000/fff.gif', [$webAllowedExtensionFilter]),
    new WebResource('object_three.png', 'https://dummyimage.com/100x100/000/fff', [$webPngSizeFilter, $webAllowedExtensionFilter]),
    new LocalResource('imagem', '/home/test/images/test.jpg', [$localJpgSizeFilter]),
    new LocalResource('composer.json', '/home/test/project/composer.json', [$localAllowedExtensionFilter]),
]);

//Make download prepared files
$duf->download();

//Add google cloud storage bucket name
$duf->addBucket('meubucket666');

//Upload downloaded files to bucket and get results
$fileResults = $duf->upload();

// Iterate results and get result path
foreach ($fileResults as $fileResult) {
    echo (string)$fileResult.'';
}
//You can dump result objects to see more details

//Working with result object:
/** @var File $fileResult */
foreach ($fileResults as $fileResult) {
    if($fileResult->hasError()){
        echo "File {$fileResult->getName()} contains error: {$fileResult->getErrorMessage()}";
        continue;
    }
    echo "File {$fileResult->getName()} uploaded sucessfull";
}

//Write your own filters

use JeanSouzaK\Duf\Filter\PathFilterable;
use JeanSouzaK\Duf\Filter\HeaderFilterable;
use JeanSouzaK\Duf\Filter\Filterable;

//Local files filter
class MyLocalFilter implements Filterable, PathFilterable
{
     public function applyPathFilters(array $filePathInfo)
     {
         //throw exception with message
     }
}

//Web files filter
class MyWebFilter implements Filterable, HeaderFilterable
{
     public function applyHeaderFilter(array $fileHeadersInfo)
     {
         //throw exception with message
     }
}
```

###  Health Score

30

—

LowBetter than 65% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

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 ~92 days

Recently: every ~155 days

Total

14

Last Release

991d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/390ee67bafaa0fb541491ef0e0c410fed003f655667ea1fd26ffdbbfa9bfb6b0?d=identicon)[jeansouzak](/maintainers/jeansouzak)

---

Top Contributors

[![jeansouzak](https://avatars.githubusercontent.com/u/7017700?v=4)](https://github.com/jeansouzak "jeansouzak (24 commits)")

---

Tags

bucketdownloadfetchfile-uploadfilesgcpgoogle-storagepackagephpuploadurl

### Embed Badge

![Health badge](/badges/jeansouzak-duf/health.svg)

```
[![Health](https://phpackages.com/badges/jeansouzak-duf/health.svg)](https://phpackages.com/packages/jeansouzak-duf)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k511.3M2.2k](/packages/aws-aws-sdk-php)[google/cloud

Google Cloud Client Library

1.2k16.2M54](/packages/google-cloud)[stechstudio/laravel-zipstream

A fast and simple streaming zip file downloader for Laravel.

4633.7M3](/packages/stechstudio-laravel-zipstream)[fof/upload

The file upload extension for the Flarum forum with insane intelligence.

188171.7k15](/packages/fof-upload)[uploadcare/uploadcare-php

Uploadcare PHP integration handles uploads and further operations with files by wrapping Upload and REST APIs.

1022.5M6](/packages/uploadcare-uploadcare-php)[azure-oss/storage

Azure Blob Storage PHP SDK

37985.0k5](/packages/azure-oss-storage)

PHPackages © 2026

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