|
@@ -14,7 +14,6 @@ import org.apache.commons.lang.StringUtils;
|
|
import org.springframework.beans.factory.InitializingBean;
|
|
import org.springframework.beans.factory.InitializingBean;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
-import org.springframework.util.FileCopyUtils;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
|
@@ -76,7 +75,7 @@ public class FileController implements InitializingBean {
|
|
File full = new File(baseDir, filePath);
|
|
File full = new File(baseDir, filePath);
|
|
if (full.exists()) {
|
|
if (full.exists()) {
|
|
try {
|
|
try {
|
|
- FileCopyUtils.copy(new FileInputStream(full), response.getOutputStream());
|
|
|
|
|
|
+ IOUtils.copy(new FileInputStream(full), response.getOutputStream());
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
response.sendError(500, "read file faile: " + full.getAbsolutePath());
|
|
response.sendError(500, "read file faile: " + full.getAbsolutePath());
|
|
}
|
|
}
|
|
@@ -96,9 +95,12 @@ public class FileController implements InitializingBean {
|
|
File full = new File(baseDir, filePath);
|
|
File full = new File(baseDir, filePath);
|
|
if (full.exists()) {
|
|
if (full.exists()) {
|
|
try {
|
|
try {
|
|
- response.addHeader("x-upyun-file-type", full.isFile() ? "file" : "folder");
|
|
|
|
- response.addHeader("x-upyun-file-size", String.valueOf(full.length()));
|
|
|
|
- response.addHeader("x-upyun-file-date", String.valueOf(full.lastModified()));
|
|
|
|
|
|
+ response.addHeader(UpYun.X_UPYUN_FILE_TYPE, full.isFile() ? "file" : "folder");
|
|
|
|
+ response.addHeader(UpYun.X_UPYUN_FILE_SIZE, String.valueOf(full.length()));
|
|
|
|
+ response.addHeader(UpYun.X_UPYUN_FILE_DATE, String.valueOf(full.lastModified()));
|
|
|
|
+ if (full.isFile()) {
|
|
|
|
+ response.addHeader(UpYun.CONTENT_MD5, UpYun.md5(full));
|
|
|
|
+ }
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
response.sendError(500, "read file faile: " + full.getAbsolutePath());
|
|
response.sendError(500, "read file faile: " + full.getAbsolutePath());
|
|
}
|
|
}
|