{"id":41451878,"url":"https://github.com/mitoop/laravel-alioss-storage","last_synced_at":"2026-01-23T15:28:30.578Z","repository":{"id":57017695,"uuid":"153655113","full_name":"mitoop/laravel-alioss-storage","owner":"mitoop","description":"Laravel Aliyun OSS Filesystem Storage","archived":false,"fork":false,"pushed_at":"2024-12-23T04:02:07.000Z","size":26,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-21T01:17:16.074Z","etag":null,"topics":["alioss","laravel-alioss-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/mitoop.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":"2018-10-18T16:33:33.000Z","updated_at":"2024-12-23T04:01:49.000Z","dependencies_parsed_at":"2022-08-22T11:31:41.846Z","dependency_job_id":null,"html_url":"https://github.com/mitoop/laravel-alioss-storage","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/mitoop/laravel-alioss-storage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitoop%2Flaravel-alioss-storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitoop%2Flaravel-alioss-storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitoop%2Flaravel-alioss-storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitoop%2Flaravel-alioss-storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitoop","download_url":"https://codeload.github.com/mitoop/laravel-alioss-storage/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitoop%2Flaravel-alioss-storage/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28694522,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T14:15:13.573Z","status":"ssl_error","status_checked_at":"2026-01-23T14:09:05.534Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["alioss","laravel-alioss-storage"],"created_at":"2026-01-23T15:28:28.222Z","updated_at":"2026-01-23T15:28:30.569Z","avatar_url":"https://github.com/mitoop.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Aliyun OSS Filesystem Storage\n\n## Install\n\u003e composer require mitoop/laravel-alioss-storage\n\nLaravel 版本低于5.5版本 请添加`Mitoop\\AliOSS\\ServiceProvider` 到 `config/app.php` 的 `providers` 数组\n\nLaravel 9 起 依赖 `league/flysystem` 版本发生变化, 接口约束也发生了变化\n\n## Require\n   - \u003e Laravel 5+ \u0026\u0026 \u003c Laravel 9\n\n## Configure\n在 `config/filesystems.php` 的 `disk`里增加配置:\n```\n 'oss' =\u003e [ // 定义的disk名称, 自定义，只要不重复就行\n    'driver'            =\u003e 'oss', // 使用的驱动，这里只能填写 `oss` [必填]\n    'access_key_id'     =\u003e env('OSS_ACCESS_ID', 'access_key_id'), // OSS access_key_id [必填]\n    'access_key_secret' =\u003e env('OSS_ACCESS_KEY', 'access_key_secret'), // OSS access_key_secret [必填]\n    'endpoint'          =\u003e env('OSS_ENDPOINT', 'endpoint'), // OSS endpoint [必填]\n    'bucket'            =\u003e env('OSS_BUCKET', 'bucket'), // OSS bucket [必填]\n    'custom_domain'     =\u003e 'http://foo.bar', // 自定义域名， 参考下方说明\n    'schema'            =\u003e env('OSS_SCHEMA', 'https'), // 使用默认域名时用的 url schema, 参考下方说明\n    'plugins'           =\u003e [], // 可以自己封装插件，实现更多方法 参考下方说明\n ],\n\n  说明:\n  1. 自定义域名\n  获取 OSS URL 的时候，默认地址是 bucket.endpoint/path，指定 schema 后为 http(s)://bucket.endpoint/path\n  当使用自定义域名后, 就不再使用默认地址，schema 此时就不起作用了, 获取地址变为：自定义域名/path\n  \n  2. 插件\n  如果要实现更多方法，在 `plugins` 里添加上对应类， 例如\n  'plugins' =\u003e [\n      DoSomethingPlugin::class,\n  ],\n  插件类应该继承 `\\Mitoop\\AliOSS\\PluginsAbstractPlugin` \n  或者继承 `League\\Flysystem\\Plugin\\AbstractPlugin`\n```  \n      \n## Use\n可以使用 Laravel Storage 的所有方法\n\n集成插件提供的方法 :\n- signUrl \n  ```\n  使用签名URL进行临时授权(主要对私有对象使用). \n  \n  Storage::disk('oss')-\u003esignUrl($path, $timeout);\n  ```\n- putRemoteFile \n  ```\n  将本地文件或者远程URL文件存储到oss. \n  \n  Storage::disk('oss')-\u003eputRemoteFile($path, $remoteUrl);\n  ```\n\n## Notice\n\n1. `deleteDir` 删除文件夹方法. 方法直接返回为 false, 不会进行删除，如果要删除文件夹强烈推荐到阿里云后台操作.\n\n2. `listContents` 列出文件夹目录(支持递归)方法. 方法直接返回为空数组 [], 如果有此业务，可以考虑通过插件实现.\n\n3. 除了 `has` 方法, 所有方法在失败的时候都会返回 false (不抛出异常，但有日志记录),\n   \n   如果需要, 你可以用 === false 来判断是否成功. 配置正常的情况下, 失败概率极低.\n\n3. `has` 方法, 本身返回 true / false, 所以发生错误会抛出异常.\n\n4. `$request-\u003efile('avatar')-\u003estore('avatars');` 上传文件直接 `store` 就生成随机名称，这里的 `avatars` 只是目录名称\n\n   所以推荐使用 `storeAs` 方法来达到预期的目的.\n   \n   曾经遇到过 `store` 方法生成随机名称获取扩展的时候，对于 WPS 的 docx/pptx, 总是获取不到正确的文件扩展名称\n   \n   最后 `storeAs` 手动解决了.\n\n5. `temporaryUrl` 方法和 `signUrl` 是一样的效果, 区别仅在于第二个参数\n\n   `signUrl` 传入的 int 类型, 例如, 传入30表示30秒后过期\n   \n   `temporaryUrl` 传入的是 `\\DateTimeInterface` 类型, 例如, 传入 now()-\u003eaddSeconds(30) 也是表示30秒后过期\n\n## More\n\nStorage方法通常会提供 `options` 参数. 最常用的就是设置文件可见性.\n\n设置可见性：\n```\n// 只设置可见行，直接 public\nStorage::disk('oss')-\u003eput('file.jpg', $contents, 'public');\n或\n// 还有其他 option 配置时使用 ['visibility' =\u003e 'private']\nStorage::disk('oss')-\u003eput('file.jpg', $contents, ['visibility' =\u003e 'private']) \n\npublic 对应 OSS 的公开读权限\nprivate 对应 OSS 的私有权限\n不单独设置可见性, 默认继承 bucket 的可见性 \n```\n\n## Links\n[https://github.com/laravel/framework/tree/7.x/src/Illuminate/Filesystem](https://github.com/laravel/framework/tree/7.x/src/Illuminate/Filesystem)\n\n[https://github.com/thephpleague/flysystem](https://github.com/thephpleague/flysystem)\n\n[https://help.aliyun.com/document_detail/32099.html](https://help.aliyun.com/document_detail/32099.html)\n\n[https://github.com/jacobcyl/Aliyun-oss-storage](https://github.com/jacobcyl/Aliyun-oss-storage)\n\n[https://github.com/thephpleague/flysystem-aws-s3-v3](https://github.com/thephpleague/flysystem-aws-s3-v3)\n\n[https://github.com/apollopy/flysystem-aliyun-oss](https://github.com/apollopy/flysystem-aliyun-oss)\n\n## License\n```\n        DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE \n                    Version 2, December 2004 \n\n Copyright (C) 2004 Sam Hocevar \u003csam@hocevar.net\u003e \n\n Everyone is permitted to copy and distribute verbatim or modified \n copies of this license document, and changing it is allowed as long \n as the name is changed. \n\n            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE \n   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION \n\n  0. You just DO WHAT THE FUCK YOU WANT TO.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitoop%2Flaravel-alioss-storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitoop%2Flaravel-alioss-storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitoop%2Flaravel-alioss-storage/lists"}