不懂就问, laravel后端阿里云OSS上传会占用到服务器资源吗?
比如,在上传到OSS的时候,是否会占用到服务器的带宽或是CPU?
或是只能用TST权鉴在前端上传的方式么?
谢谢大家~
namespace App\Services;
use Illuminate\Support\Facades\Storage;
class OssService //extends BaseService
{
//上传到阿里云OSS服务
public static function Up($file)
{
$disk = Storage::disk('oss'); //指定上传磁盘为阿里云oss
$date = date("Y-m-d"); //时间
$path = "web/$date"; //OSS中上传目录,baochiq加上日期为目录
$str = mt_rand();
$dataNewName = 'month_' . $date . '_' . time() . '_' . $str . '.' . $file->getClientOriginalExtension(); //重新组名字和后缀
$path = $disk->putFileAs($path, $file, $dataNewName); //上传文件到指定目录和重新命名,路径 上传的文件 新名字。
return $path;
}
}
推荐文章: