Compare commits

..

2 Commits

Author SHA1 Message Date
小王 062ec9e009 返回的文件加上后缀 2024-09-19 17:26:36 +08:00
小王 7f8967d550 上传的文件文件保留原名 2024-09-19 17:20:19 +08:00
3 changed files with 18 additions and 5 deletions

View File

@ -43,7 +43,7 @@ steps:
password:
from_secret: hub_password
repo: anxan-docker.pkg.coding.net/d/repo/micro-php-nacos
tags: "0.0.8"
tags: "0.0.9"
- name: "完成通知"
image: anxan-docker.pkg.coding.net/d/repo/drone-email-notify:1.0

View File

@ -2,7 +2,7 @@
-
- docker运行命令
```bash
docker run -d --name php-file-server -p 8000:80 -v /your/path:/var/www/html/public -e NACOS_ADDR=192.168.1.105:8848 -e SERVICE_PORT=8000 -e ORIGIN_URL=file.zeroerr.cn anxan-docker.pkg.coding.net/d/repo/micro-php-nacos:0.0.8
docker run -d --name php-file-server -p 8000:80 -v /your/path:/var/www/html/public -e NACOS_ADDR=192.168.1.105:8848 -e SERVICE_PORT=8000 -e ORIGIN_URL=file.zeroerr.cn anxan-docker.pkg.coding.net/d/repo/micro-php-nacos:0.0.9
```
- docker-compose.yml
```bash
@ -12,7 +12,7 @@ networks:
services:
micro-php-nacos:
image: anxan-docker.pkg.coding.net/d/repo/micro-php-nacos:0.0.8
image: anxan-docker.pkg.coding.net/d/repo/micro-php-nacos:0.0.9
container_name: micro-php-nacos
restart: unless-stopped
networks:
@ -37,6 +37,7 @@ services:
|`ORIGIN_URL`| 允许跨域的网址 |`{docker容器内ip}:8000`|-|
|`NAMESPACE_ID`| 要注册NACOS命名空间 |`0a1c32f2-dea1-4ec1-b546-cb4635cd7db2`|-|
|`SERVICE_NAME`| 微服务名称 |`zeroerroa-file`|-|
|`APP_DEBUG`| 是否开启调试模式 |`false`|-|
内部暴露的端口
-

View File

@ -32,15 +32,27 @@ class Index
// 允许跨域的域名
$originUrl = $env->get('ORIGIN_URL', $serverIP . ':' . $servicePort);
// 获取文件原文件名
$trueName = $file->getOriginalName();
// 获取文件后缀名
$ext = $file->extension();
// 生成新文件名
$trueName = rtrim($trueName, ".$ext");
$fileName = $trueName . '_' . date('His') . '.' . $ext;
// 保存文件
// $file = $file->move(public_path() . 'uploads', $fileName);
// 组装保存路径
$savename = \think\facade\Filesystem::disk('upload')->putFile('uploads', $file);
$savename = \think\facade\Filesystem::disk('upload')->putFileAs('uploads' . '/' . date('Ymd'), $file, $fileName);
$savename = str_replace('\\', '/', $savename);
return json([
'code' => 200,
'msg' => null,
'data' => [
"name" => $trueName,
"name" => $trueName . '.' . $ext,
"url" => '//' . $originUrl . '/' . $savename,
// "url" => 'http://192.168.1.105:8080/file/' . $savename,
],