|
@@ -12,6 +12,11 @@ import java.net.URL;
|
|
|
location /manual/ {
|
|
location /manual/ {
|
|
|
alias /file/images/eden/manual/;
|
|
alias /file/images/eden/manual/;
|
|
|
}*/
|
|
}*/
|
|
|
|
|
+
|
|
|
|
|
+/*images目录下其他目录也公开读写权限
|
|
|
|
|
+sudo chmod 777 -R /file/images/
|
|
|
|
|
+恢复默认权限
|
|
|
|
|
+sudo chmod 755 /file/images/*/
|
|
|
public class WebImageTool {
|
|
public class WebImageTool {
|
|
|
private static final String PATH_AUTO_FOLDER = "/file/images/eden/auto/";
|
|
private static final String PATH_AUTO_FOLDER = "/file/images/eden/auto/";
|
|
|
private static final String CMD_GET_AUTO_FILE_COUNT = "ls -l " + PATH_AUTO_FOLDER + " | grep \"^-\"|wc -l";
|
|
private static final String CMD_GET_AUTO_FILE_COUNT = "ls -l " + PATH_AUTO_FOLDER + " | grep \"^-\"|wc -l";
|
|
@@ -45,7 +50,8 @@ public class WebImageTool {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 获取下一文件名
|
|
// 获取下一文件名
|
|
|
- int futureFileCount = getFilesCount(CMD_GET_AUTO_FILE_COUNT) + 1;
|
|
|
|
|
|
|
+ //int futureFileCount = getFilesCount(CMD_GET_AUTO_FILE_COUNT) + 1;
|
|
|
|
|
+ int futureFileCount = getFilesCount(folder) + 1;
|
|
|
File file = new File(folder, String.valueOf(futureFileCount) + format);
|
|
File file = new File(folder, String.valueOf(futureFileCount) + format);
|
|
|
if (file.exists()) {
|
|
if (file.exists()) {
|
|
|
file.delete();
|
|
file.delete();
|
|
@@ -102,6 +108,18 @@ public class WebImageTool {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static int getFilesCount(File folderFile) {
|
|
|
|
|
+ if (folderFile == null) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String[] files = folderFile.list();
|
|
|
|
|
+ if (files == null) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return files.length;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取文件目录的文件数
|
|
* 获取文件目录的文件数
|
|
@@ -112,11 +130,11 @@ public class WebImageTool {
|
|
|
try {
|
|
try {
|
|
|
Process p = Runtime.getRuntime().exec(commandStr);
|
|
Process p = Runtime.getRuntime().exec(commandStr);
|
|
|
br = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
|
br = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
|
|
- String line = null;
|
|
|
|
|
|
|
+ /*String line = null;
|
|
|
StringBuilder sb = new StringBuilder();
|
|
StringBuilder sb = new StringBuilder();
|
|
|
while ((line = br.readLine()) != null) {
|
|
while ((line = br.readLine()) != null) {
|
|
|
sb.append(line + "\n");
|
|
sb.append(line + "\n");
|
|
|
- }
|
|
|
|
|
|
|
+ }*/
|
|
|
return Integer.parseInt(br.readLine());
|
|
return Integer.parseInt(br.readLine());
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|