.
This commit is contained in:
parent
f970fd9e5e
commit
9e597e5d84
@ -1,13 +1,3 @@
|
||||
# 是否开发模式
|
||||
isDev=true
|
||||
|
||||
----------- arango conf ----------
|
||||
arango.host=101.132.161.85
|
||||
arango.port=8529
|
||||
arango.database=redbbs
|
||||
arango.user=root
|
||||
arango.password=lxgwzswhp0zj
|
||||
|
||||
----------- file conf ----------
|
||||
file.upload_dir=D:/wk/_own/redbbs/root/file_pub/
|
||||
file.view_path=http://127.0.0.1/file_pub/
|
||||
file.upload_dir=${APP_HOME}/root/upload/
|
||||
file.view_path=http://127.0.0.1/upload/
|
||||
|
61
pom.xml
61
pom.xml
@ -37,6 +37,12 @@
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.22</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- arangodb支持 -->
|
||||
<!-- arangodb支持 -->
|
||||
@ -53,17 +59,66 @@
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>redbbs</finalName>
|
||||
<!--<directory>lib</directory>-->
|
||||
<finalName>lib/redbbs</finalName>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
<source>14</source>
|
||||
<target>14</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<executions>
|
||||
<!-- 依赖 jar 拷贝 -->
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/lib</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- 配置文件拷贝 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-files</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/conf</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>conf</directory>
|
||||
<includes>
|
||||
<include>application.xml</include>
|
||||
<include>conf.txt</include>
|
||||
<include>persistence.xml</include>
|
||||
<!-- 可以添加其他文件的 include 配置 -->
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -10,7 +10,6 @@ import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
/**
|
||||
* Created by Lxy at 2017/10/3 13:48.
|
||||
@ -19,9 +18,9 @@ import java.nio.file.StandardCopyOption;
|
||||
public class FileService extends BaseService {
|
||||
|
||||
@Resource(name = "property.file.upload_dir")
|
||||
private String dir = "";
|
||||
private String dir = "./root/upload/";
|
||||
@Resource(name = "property.file.view_path")
|
||||
private String view = "";
|
||||
private String view = "http://127.0.0.1/upload/";
|
||||
private String format = "%1$tY%1$tm%1$td%1$tH%1$tM%1$tS";
|
||||
|
||||
@RestMapping(name = "upload", comment = "文件上传")
|
||||
@ -30,12 +29,12 @@ public class FileService extends BaseService {
|
||||
String suffix = name.substring(name.lastIndexOf("."));
|
||||
String path = String.format(format, System.currentTimeMillis()) + suffix;
|
||||
File destFile = new File(dir + path);
|
||||
destFile.getParentFile().mkdir();
|
||||
destFile.getParentFile().mkdirs();
|
||||
if (!tmpFile.renameTo(destFile)) {
|
||||
try {
|
||||
Files.copy(tmpFile.toPath(), destFile.toPath(), StandardCopyOption.ATOMIC_MOVE);
|
||||
Files.copy(tmpFile.toPath(), destFile.toPath());
|
||||
} finally {
|
||||
tmpFile.delete();//删除临时文件
|
||||
//tmpFile.delete();//删除临时文件
|
||||
}
|
||||
}
|
||||
RetResult result = RetResult.success();
|
||||
|
@ -2,6 +2,7 @@ package net.tccn.bbs.servlet;
|
||||
|
||||
import net.tccn.bbs.base.BaseServlet;
|
||||
import org.redkale.net.http.*;
|
||||
import org.redkale.util.Utility;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
@ -35,12 +36,12 @@ public class FileServlet extends BaseServlet {
|
||||
String name = part.getName();
|
||||
String suffix = name.substring(name.lastIndexOf("."));
|
||||
String path = String.format(format, System.currentTimeMillis()) + suffix;
|
||||
File destFile = new File(dir + path);
|
||||
destFile.getParentFile().mkdir();
|
||||
File destFile = new File(dir + Utility.todayYYMMDD() + "/" + path);
|
||||
destFile.getParentFile().mkdirs();
|
||||
|
||||
part.save(destFile);
|
||||
|
||||
data.add(view + path);
|
||||
data.add(view + Utility.todayYYMMDD() + "/" + path);
|
||||
}
|
||||
ret.put("data", data);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user