You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
user_center/app/Http/Controllers/Api/CommonController.php

35 lines
916 B

4 years ago
<?php
namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
/**
* @title CommonController
* @description CommonController
* @package App\Http\Controllers\Api
* @author zcstatham
*/
class CommonController extends BaseController
{
protected $rules = [
'upload' => [
'rules' => [
'file' => 'required',
'file_type' => 'required'
]
]
];
public function upload(Request $request) {
$file = $request->file('file');
$fileType = $request->input('file_type','files');
$disk = Storage::disk('oss');
$filename = $disk->putFile($fileType."/".date('Ymd'), $file);
$url = str_replace('http://bmoc-files.oss-cn-hangzhou.aliyuncs.com', 'http://images.banmacar.com', $disk->getUrl($filename));
return $this->success(['url' => $url]);
}
}