Download the PHP package mitoop/laravel-alioss-storage without Composer
On this page you can find all versions of the php package mitoop/laravel-alioss-storage. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mitoop/laravel-alioss-storage
More information about mitoop/laravel-alioss-storage
Files in mitoop/laravel-alioss-storage
Package laravel-alioss-storage
Short Description Aliyun OSS storage in laravel.
License MIT
Informations about the package laravel-alioss-storage
Laravel Aliyun OSS Filesystem Storage
Install
composer require mitoop/laravel-alioss-storage
Laravel 版本低于5.5版本 请添加Mitoop\AliOSS\ServiceProvider 到 config/app.php 的 providers 数组
Laravel 9 起 依赖 league/flysystem 版本发生变化, 接口约束也发生了变化
Require
-
Laravel 5+ && < Laravel 9
Configure
在 config/filesystems.php 的 disk里增加配置:
Use
可以使用 Laravel Storage 的所有方法
集成插件提供的方法 :
-
signUrl
- putRemoteFile
Notice
-
deleteDir删除文件夹方法. 方法直接返回为 false, 不会进行删除,如果要删除文件夹强烈推荐到阿里云后台操作. -
listContents列出文件夹目录(支持递归)方法. 方法直接返回为空数组 [], 如果有此业务,可以考虑通过插件实现. -
除了
has方法, 所有方法在失败的时候都会返回 false (不抛出异常,但有日志记录),如果需要, 你可以用 === false 来判断是否成功. 配置正常的情况下, 失败概率极低.
-
has方法, 本身返回 true / false, 所以发生错误会抛出异常. -
$request->file('avatar')->store('avatars');上传文件直接store就生成随机名称,这里的avatars只是目录名称所以推荐使用
storeAs方法来达到预期的目的.曾经遇到过
store方法生成随机名称获取扩展的时候,对于 WPS 的 docx/pptx, 总是获取不到正确的文件扩展名称最后
storeAs手动解决了. -
temporaryUrl方法和signUrl是一样的效果, 区别仅在于第二个参数signUrl传入的 int 类型, 例如, 传入30表示30秒后过期temporaryUrl传入的是\DateTimeInterface类型, 例如, 传入 now()->addSeconds(30) 也是表示30秒后过期
More
Storage方法通常会提供 options 参数. 最常用的就是设置文件可见性.
设置可见性:
Links
https://github.com/laravel/framework/tree/7.x/src/Illuminate/Filesystem
https://github.com/thephpleague/flysystem
https://help.aliyun.com/document_detail/32099.html
https://github.com/jacobcyl/Aliyun-oss-storage
https://github.com/thephpleague/flysystem-aws-s3-v3
https://github.com/apollopy/flysystem-aliyun-oss