{"id":21581135,"url":"https://github.com/fightbulc/simplon_gstorage","last_synced_at":"2025-09-04T02:35:53.432Z","repository":{"id":57051451,"uuid":"56066498","full_name":"fightbulc/simplon_gstorage","owner":"fightbulc","description":"Google Cloud Storage API (service account client)","archived":false,"fork":false,"pushed_at":"2017-03-18T18:51:04.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-17T10:35:24.037Z","etag":null,"topics":["api","cdn","cloud","google","storage"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fightbulc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-12T13:42:26.000Z","updated_at":"2017-03-18T18:52:34.000Z","dependencies_parsed_at":"2022-08-24T03:40:49.726Z","dependency_job_id":null,"html_url":"https://github.com/fightbulc/simplon_gstorage","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/fightbulc/simplon_gstorage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fightbulc%2Fsimplon_gstorage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fightbulc%2Fsimplon_gstorage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fightbulc%2Fsimplon_gstorage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fightbulc%2Fsimplon_gstorage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fightbulc","download_url":"https://codeload.github.com/fightbulc/simplon_gstorage/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fightbulc%2Fsimplon_gstorage/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273542493,"owners_count":25124165,"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","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["api","cdn","cloud","google","storage"],"created_at":"2024-11-24T14:11:20.640Z","updated_at":"2025-09-04T02:35:53.406Z","avatar_url":"https://github.com/fightbulc.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cpre\u003e\n     _                 _                         _\n ___(_)_ __ ___  _ __ | | ___  _ __     __ _ ___| |_ ___  _ __ __ _  __ _  ___\n/ __| | '_ ` _ \\| '_ \\| |/ _ \\| '_ \\   / _` / __| __/ _ \\| '__/ _` |/ _` |/ _ \\\n\\__ \\ | | | | | | |_) | | (_) | | | | | (_| \\__ \\ || (_) | | | (_| | (_| |  __/\n|___/_|_| |_| |_| .__/|_|\\___/|_| |_|  \\__, |___/\\__\\___/|_|  \\__,_|\\__, |\\___|\n                |_|                    |___/                        |___/\n\u003c/pre\u003e\n\n# Requirements\n\nYou need `Server account credentials` as `JSON` which you can generate within your `Google Console`.\nYou will receive a file which looks like the following example:\n\n```json\n{\n  \"type\": \"service_account\",\n  \"project_id\": \"foo.bar:api-project-XXXXXXXXXXXXXX\",\n  \"private_key_id\": \"XXXXXXXXXXXXXX\",\n  \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nXXXXXXXXXXXXXX\\n-----END PRIVATE KEY-----\\n\",\n  \"client_email\": \"cloud-storage-web-server@api-project-XXXXXXXXXXXXXX.foo.bar.iam.gserviceaccount.com\",\n  \"client_id\": \"XXXXXXXXXXXXXX\",\n  \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n  \"token_uri\": \"https://accounts.google.com/o/oauth2/token\",\n  \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n  \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/cloud-storage-web-server%40api-project-XXXXXXXXXXXXXX.foo.bar.iam.gserviceaccount.com\"\n}\n```\n\n# Setup credentials\n\nGstorage needs your credentials in order to be constructed. For this we need to use the `ServerAccountCredentials` which offers two methods to load our credentials.\n\n## Load from params\n\nUse `client_email` and `private_key` from your JSON file above for this method.\n\n```php\n$credentials = (new ServerAccountCredentials())-\u003eloadFromParams(\n    \"cloud-storage-web-server@api-project-XXXXXXXXXXXXXX.foo.bar.iam.gserviceaccount.com\",\n    \"-----BEGIN PRIVATE KEY-----\\nXXXXXXXXXXXXXX\\n-----END PRIVATE KEY-----\\n\"\n);\n```\n\n## Load from JSON file\n\nSpecify the file path for your JSON file. Lets assume we saved our file within the same folder and named it `credentials.json`.\n\n```php\n$credentials = (new ServerAccountCredentials())-\u003eloadFromJsonFile('credentials.json');\n```\n\n# Instantiate Gstorage class\n\nNow all what needs to be done is to use `$credentials`:\n\n```php\n$gstorage = new Gstorage($credentials);\n```\n\n# Upload a file\n\nLets upload a file. We will construct an upload object and receive a simple object back.\n\n```php\n// upload object\n$data = new UploadData('YOUR-BUCKET-NAME');\n\n// load file via URL\n$data-\u003eloadWithFile('https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png');\n\n// upload file\n$objectData = $gstorage-\u003eupload($data); // ObjectData|null\n\nif ($objectData)\n{\n    var_dump([\n        'bucket'     =\u003e $objectData-\u003egetBucket(),\n        'id'         =\u003e $objectData-\u003egetFileName(),\n        'url_public' =\u003e $objectData-\u003egetUrlPublic(),\n    ]);\n}\n```\n\n## Upload via BLOB\n\nIn case you have the file data already you can upload your data as following:\n\n```php\n// our blob\n$blob = file_get_contents('https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png');\n\n// upload object\n$data = new UploadData('YOUR-BUCKET-NAME');\n\n// load file via BLOB\n$data-\u003eloadWithBlob('google-logo.png', $blob);\n\n// upload file\n$objectData = $gstorage-\u003eupload($data); // ObjectData|null\n\nif ($objectData)\n{\n    var_dump([\n        'bucket'     =\u003e $objectData-\u003egetBucket(),\n        'id'         =\u003e $objectData-\u003egetFileName(),\n        'url_public' =\u003e $objectData-\u003egetUrlPublic(),\n    ]);\n}\n```\n\n# Delete file\n\nLets delete the upload from our `Google Logo Blob`:\n\n```php\n$response = $gstorage-\u003edelete(\n    new ObjectData('YOUR-BUCKET-NAME', 'google-logo.png')\n);\n\nvar_dump($response); // true|false\n```\n\n# Complete example\n\n```php\n$gstorage = new Gstorage(\n    (new ServerAccountCredentials())-\u003eloadFromJsonFile('credentials.json')\n);\n\n// upload object\n$data = new UploadData('YOUR-BUCKET-NAME');\n\n// load file via URL\n$data-\u003eloadWithFile('https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png');\n\n// upload file\n$objectData = $gstorage-\u003eupload($data); // ObjectData|null\n\nif ($objectData)\n{\n    var_dump([\n        'bucket'     =\u003e $objectData-\u003egetBucket(),\n        'id'         =\u003e $objectData-\u003egetFileName(),\n        'url_public' =\u003e $objectData-\u003egetUrlPublic(),\n    ]);\n}\n```\n\n# License\nCirrus is freely distributable under the terms of the MIT license.\n\nCopyright (c) 2016 Tino Ehrich ([tino@bigpun.me](mailto:tino@bigpun.me))\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffightbulc%2Fsimplon_gstorage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffightbulc%2Fsimplon_gstorage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffightbulc%2Fsimplon_gstorage/lists"}