{"id":36971757,"url":"https://github.com/jeansouzak/duf","last_synced_at":"2026-01-13T21:54:38.577Z","repository":{"id":45364595,"uuid":"263278602","full_name":"jeansouzak/duf","owner":"jeansouzak","description":"DUF (Download and Upload Files) - Fetch URL file, download and upload to a service with this package","archived":false,"fork":false,"pushed_at":"2023-08-22T14:37:57.000Z","size":63,"stargazers_count":10,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-18T13:21:24.928Z","etag":null,"topics":["bucket","download","fetch","file-upload","files","gcp","google-storage","package","php","upload","url"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeansouzak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-12T08:31:35.000Z","updated_at":"2023-08-11T15:06:13.000Z","dependencies_parsed_at":"2022-08-31T03:23:14.402Z","dependency_job_id":null,"html_url":"https://github.com/jeansouzak/duf","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/jeansouzak/duf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeansouzak%2Fduf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeansouzak%2Fduf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeansouzak%2Fduf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeansouzak%2Fduf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeansouzak","download_url":"https://codeload.github.com/jeansouzak/duf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeansouzak%2Fduf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28401546,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bucket","download","fetch","file-upload","files","gcp","google-storage","package","php","upload","url"],"created_at":"2026-01-13T21:54:33.637Z","updated_at":"2026-01-13T21:54:38.565Z","avatar_url":"https://github.com/jeansouzak.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Duf - PHP Download and Upload Files\nDuf is a PHP package to download files from web/local and upload to other servers (Google Cloud Storage).\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\".github/duf.png?raw=true\" width=\"55%\"\u003e\n\u003cp\u003e\n    \n\n\n- First package version: Download resources from web and local to upload to Google Cloud Storage ☑\n- Second package version: Create Duffer adapter to upload to Amazon S3 ☐\n\n## Installing Duf\n\nThe recommended way to install Duf is through\n[Composer](https://getcomposer.org/).\n\n```bash\ncomposer require jeansouzak/duf\n```\n\n## How it works:\n```php\n\nuse JeanSouzaK\\Duf\\Duff;\nuse JeanSouzaK\\Duf\\Prepare\\WebResource;\n\n$duf = Duff::getInstance(Duff::GOOGLE_CLOUD_STORAGE, [\n    'project_id' =\u003e 'storage-test-227305',\n    'key_path' =\u003e '/home/env/storage-test-227305-8472347a39489.json'\n]);\n\n// - Chaining example -\n$uploadResults = $duf-\u003eprepare([\n    new WebResource('teste.png', 'https://dummyimage.com/600x400/000/fff')\n])-\u003edownload()-\u003eaddBucket('meubucket666')-\u003eupload();\n\n\n// - Step-by-step example -\n//Prepare object name and url\n$duf-\u003eprepare([\n    new WebResource('object_one.png', 'https://dummyimage.com/600x400/000/fff'),\n    new WebResource('object_two.png', 'https://dummyimage.com/300x200/000/fff'),\n    new WebResource('object_three.png', 'https://dummyimage.com/100x100/000/fff')    \n]);\n\n\n//Make download prepared files\n$duf-\u003edownload();\n\n//Add google cloud storage bucket name\n$duf-\u003eaddBucket('meubucket666');\n\n//Upload downloaded files to bucket and get results\n$uploadResults = $duf-\u003eupload();\n\n// Iterate results and get result path\necho '\u003cpre\u003e';\nforeach ($uploadResults as $uploadResult) {    \n    print_r($uploadResult);\n    echo (string)$uploadResult.'\u003cbr/\u003e';\n}\n\n```\n## Duf will help you if you desire upload a local file as well:\n```php\n\nuse JeanSouzaK\\Duf\\Duff;\nuse JeanSouzaK\\Duf\\Prepare\\LocalResource;\nuse JeanSouzaK\\Duf\\Prepare\\WebResource;\n\n//Call factory to get google cloud storage duffer\n$duf = Duff::getInstance(Duff::GOOGLE_CLOUD_STORAGE, [\n    'project_id' =\u003e 'storage-test-227305',\n    'key_path' =\u003e '/home/env/storage-test-227305-8472347a39489.json'\n]);\n\n//Uploading from local file target\n$duf-\u003eprepare([\n    new LocalResource('imagem', '/home/test/images/test.jpg')    \n]);\n\n//You can mix local and remote target file\n$duf-\u003eprepare([\n    new LocalResource('imagem', '/home/test/images/test.jpg'),\n    new WebResource('teste.png', 'https://dummyimage.com/600x400/000/fff')\n]);\n\n//Make download prepared files\n$duf-\u003edownload();\n\n//Add google cloud storage bucket name\n$duf-\u003eaddBucket('meubucket666');\n\n//Upload downloaded files to bucket and get results\n$fileResults = $duf-\u003eupload();\n\n```\n## Using filters:\n```php\n\nuse JeanSouzaK\\Duf\\Duff;\nuse JeanSouzaK\\Duf\\Prepare\\WebResource;\nuse JeanSouzaK\\Duf\\Filter\\WebFileSizeFilter;\nuse JeanSouzaK\\Duf\\Filter\\WebFileExtensionFilter;\nuse JeanSouzaK\\Duf\\Filter\\LocalFileSizeFilter;\nuse JeanSouzaK\\Duf\\Filter\\LocalFileExtensionFilter;\n\n//Call Factory to get google cloud storage duffer instance\n$duf = Duff::getInstance(Duff::GOOGLE_CLOUD_STORAGE, [\n    'project_id' =\u003e 'storage-test-227305',\n    'key_path' =\u003e '/home/env/storage-test-227305-8472347a39489.json'\n]);\n\n//[WEB Filter] Configure a maximum file size to bind in a resource\n$webPngSizeFilter = new WebFileSizeFilter(2, WebFileSizeFilter::MB);\n//[WEB Filter] Configure alloweed extensions to bind in a resource\n$webAllowedExtensionFilter = new WebFileExtensionFilter([\n    WebFileExtensionFilter::JPEG,\n    WebFileExtensionFilter::PNG    \n]);\n\n$localJpgSizeFilter = new LocalFileSizeFilter(1, 'M');\n$localAllowedExtensionFilter = new LocalFileExtensionFilter([\n    'json',\n    'doc',\n    'docx'\n]);\n\n//Prepare object name, url and filters\n$duf-\u003eprepare([\n    new WebResource('object_one.png', 'https://dummyimage.com/600x400/000/fff', [$webPngSizeFilter]),\n    new WebResource('object_two.png', 'https://dummyimage.com/600x400/000/fff.gif', [$webAllowedExtensionFilter]),\n    new WebResource('object_three.png', 'https://dummyimage.com/100x100/000/fff', [$webPngSizeFilter, $webAllowedExtensionFilter]),\n    new LocalResource('imagem', '/home/test/images/test.jpg', [$localJpgSizeFilter]),\n    new LocalResource('composer.json', '/home/test/project/composer.json', [$localAllowedExtensionFilter]),  \n]);\n\n//Make download prepared files\n$duf-\u003edownload();\n\n//Add google cloud storage bucket name\n$duf-\u003eaddBucket('meubucket666');\n\n//Upload downloaded files to bucket and get results\n$fileResults = $duf-\u003eupload();\n\n// Iterate results and get result path\nforeach ($fileResults as $fileResult) {\n    echo (string)$fileResult.'\u003cbr/\u003e';\n}\n//You can dump result objects to see more details\n\n//Working with result object:\n/** @var File $fileResult */\nforeach ($fileResults as $fileResult) {\n    if($fileResult-\u003ehasError()){\n        echo \"File {$fileResult-\u003egetName()} contains error: {$fileResult-\u003egetErrorMessage()}\u003cbr/\u003e\";\n        continue;\n    }\n    echo \"File {$fileResult-\u003egetName()} uploaded sucessfull\u003cbr/\u003e\";\n}\n\n//Write your own filters\n\nuse JeanSouzaK\\Duf\\Filter\\PathFilterable;\nuse JeanSouzaK\\Duf\\Filter\\HeaderFilterable;\nuse JeanSouzaK\\Duf\\Filter\\Filterable;\n\n//Local files filter\nclass MyLocalFilter implements Filterable, PathFilterable \n{\n     public function applyPathFilters(array $filePathInfo) \n     {\n         //throw exception with message\n     }\n} \n\n//Web files filter\nclass MyWebFilter implements Filterable, HeaderFilterable\n{\n     public function applyHeaderFilter(array $fileHeadersInfo) \n     {\n         //throw exception with message\n     }\n} \n\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeansouzak%2Fduf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeansouzak%2Fduf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeansouzak%2Fduf/lists"}