{"id":18386048,"url":"https://github.com/catlabinteractive/central-storage","last_synced_at":"2025-04-12T01:44:32.321Z","repository":{"id":37412622,"uuid":"220212747","full_name":"CatLabInteractive/central-storage","owner":"CatLabInteractive","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-09T10:14:14.000Z","size":1378,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-16T00:24:42.945Z","etag":null,"topics":["central-storage"],"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/CatLabInteractive.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-07T10:40:52.000Z","updated_at":"2024-07-09T10:14:17.000Z","dependencies_parsed_at":"2024-07-09T03:13:47.849Z","dependency_job_id":"5eda141e-f77d-4e84-8c9c-482b27b76ace","html_url":"https://github.com/CatLabInteractive/central-storage","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CatLabInteractive%2Fcentral-storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CatLabInteractive%2Fcentral-storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CatLabInteractive%2Fcentral-storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CatLabInteractive%2Fcentral-storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CatLabInteractive","download_url":"https://codeload.github.com/CatLabInteractive/central-storage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505937,"owners_count":21115354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["central-storage"],"created_at":"2024-11-06T01:20:02.573Z","updated_at":"2025-04-12T01:44:32.300Z","avatar_url":"https://github.com/CatLabInteractive.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Central Storage\n\nCentral Storage is a storage engine built in Laravel. It includes duplicate upload detection, supports on the fly image\n(but cached) image resize and allows you to set 'Processors' that handle more complex file transformations like video\ntranscoding etc.\n\n### Quick start\nCHeckout this code:\n\n```git clone git@github.com:CatLabInteractive/central-storage.git```\n\nLet composer install all dependencies:\n\n```composer install```\n\nCopy `.env.example` to `.env` and set the database credentials.\n\nSet a unique app key:\n\n```php artisan key:generate```\n\nSetup the database:\n\n```php artisan migrate```\n\nCreate a user (for security, there is no registration form enabled in the website)\n\n```php artisan user:create```\n\nDone! You should now be able to login on the website.\n\n### Disk configuration\nCentral Storage uses the default File Storage systems, so you can configure where files will be stored.\nThe files are stored in various folders based on a hashing mechanism that should in theory improve performance\nwhen reading a lot of sequentially uploaded files.\n\nNote that certain Processors (like the Elastic Transcoder processor) requires the files to be stored on Amazon S3.\n\n### Setting up a consumer\nA 'consumer' is an application that will use central storage for storing files.\n\nNavigate to `Consumers` and click `Create consumer`.\nFill in a descriptive name.\n\nYou should now get your consumer key and consumer secret.\n\n### File resize\nIn order for file resizing to work, you need to either install the GD or the Imagick php extensions. In your .env file,\nset ```INTERVENTION_DRIVER=imagick``` accordingly. The project uses the [Intervention Image](https://github.com/Intervention/image)\nlibrary to manipulate images, so for further install instructions, take a look there.\n\n### Content delivery network\nIn order to use a CDN with Central Storage (like Amazon Cloudfront), point the origin of the network to your asset website\nand configure your Central Storage Client projects `FRONT` config parameter to the CDN network. This way, uploads will \nuse the direct connection to Central Storage, but all generated links fetch content will use the CDN.\n\n## Setting up your client project (in Laravel)\nCentral Storage provides a standard REST API and is thus consumable by any language or framework. We will focus on the\nexisting Laravel client here. Note that it is a trivial task to implement a new client, as there is only a few methods\nto implement.\n\nIn your Laravel project, run\n```composer require catlabinteractive/central-storage-client```\n\nThen, wherever you want to upload a file, initialize the client:\n\n```php\n$centralStorageClient = new CentralStorageClient(\n    'https://your-central-storage-url.com',\n    'your_key',\n    'your_secret'\n);\n```\n\nOr, if you like, you can use the provider that uses the default configuration files:\n```php\n    'providers' =\u003e [\n    \n        [...]\n        \n        CatLab\\CentralStorage\\Client\\CentralStorageServiceProvider::class,\n    \n    ],\n    \n    'aliases' =\u003e [\n    \n        [...]\n        \n        'CentralStorage' =\u003e CatLab\\CentralStorage\\Client\\CentralStorageClientFacade::class,\n    \n    ]\n]\n```\n\nThe PHP client consumes Symfony's File objects. That means you can upload files straight from Laravel. The client returns\nan Eloquent model 'Asset', which can be saved directly to a database (migration file is available in `central-storage-client/database`).\n\n```php\n\u003c?php\n\nuse App\\Models\\Attachments\\Asset;\nuse Illuminate\\Http\\Request;\n\nclass AssetController\n{\n    /**\n     * @param Request $request\n     * @return \\Illuminate\\Http\\JsonResponse\n     */\n    public function upload(Request $request)\n    {\n        $file = $request-\u003efile()-\u003efirst();\n        if (!$file) {\n            abort(400, 'Please provide a valid file.');\n        }\n\n        if (!$file-\u003eisValid()) {\n            abort(400, 'File not valid: ' . $file-\u003egetErrorMessage());\n        }\n\n        /** @var Asset $asset */\n        $asset = \\CentralStorage::store($file);\n        $asset-\u003esave();\n\n        return response()-\u003ejson($asset-\u003egetData());\n    }\n}\n```\n\nFor further instructions on how to upload and consume assets, please check out the\n[Central Storage Client](https://github.com/catlabinteractive/central-storage-client) documentation.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatlabinteractive%2Fcentral-storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcatlabinteractive%2Fcentral-storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatlabinteractive%2Fcentral-storage/lists"}