|
...
|
...
|
@@ -119,7 +119,6 @@ class FileController |
|
|
|
if($file_hash !== false){
|
|
|
|
return $this->response('资源',Code::SUCCESS,$this->responseData($file_hash['path'], $name));
|
|
|
|
}
|
|
|
|
$url = $this->config['root'].$this->path;
|
|
|
|
$fileName = uniqid().rand(10000,99999).'.'.$files->getClientOriginalExtension();
|
|
|
|
//同步数据到cos
|
|
|
|
if($this->upload_location == 0){
|
|
...
|
...
|
@@ -130,12 +129,28 @@ class FileController |
|
|
|
$amazonS3Service = new AmazonS3Service();
|
|
|
|
$amazonS3Service->uploadFiles($files,$this->path,$fileName);
|
|
|
|
}
|
|
|
|
$this->synchronizationFile($files->getClientOriginalExtension(),$fileName);
|
|
|
|
$this->saveMysql($fileModel,$files->getSize(),$files->getClientOriginalExtension(),$fileName,$hash,$this->upload_location,$files->getMimeType(),$name);
|
|
|
|
$this->response('资源',Code::SUCCESS,$this->responseData($this->path.'/'.$fileName, $name));
|
|
|
|
}
|
|
|
|
|
|
|
|
//curl -X POST -F "file=@/path/to/your/file.jpg" -F "save_link=/path/to/save/directory" https://www.example.com/upload.php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :指定同步文件到獨立177服務器
|
|
|
|
* @name :synchronizationFile
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/4/8 11:10
|
|
|
|
*/
|
|
|
|
public function synchronizationFile($file_type,$fileName){
|
|
|
|
$fileTypeArr = ['zip', 'pdf', 'mp4', 'doc', 'docx', 'm4v', 'xlsx'];
|
|
|
|
if(in_array($file_type,$fileTypeArr)){
|
|
|
|
//同步到大文件
|
|
|
|
$file_path = getFileUrl($this->path.'/'.$fileName,$this->cache['storage_type'] ?? 0);
|
|
|
|
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->path.'" https://v6-file.globalso.com/upload.php';
|
|
|
|
shell_exec($cmd);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 接口上传单文件
|
...
|
...
|
|