Compare commits
3 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
2c50770204 | |
|
|
fae495fade | |
|
|
f2791d3c4e |
36
pom.xml
36
pom.xml
|
|
@ -19,40 +19,6 @@
|
|||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>8.1.8.v20121106</version>
|
||||
<configuration>
|
||||
<stopKey>stop</stopKey>
|
||||
<stopPort>5202</stopPort>
|
||||
<webAppConfig>
|
||||
<contextPath>/</contextPath>
|
||||
</webAppConfig>
|
||||
<scanIntervalSeconds>5</scanIntervalSeconds>
|
||||
<connectors>
|
||||
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
|
||||
<port>4202</port>
|
||||
<maxIdleTime>60000</maxIdleTime>
|
||||
</connector>
|
||||
</connectors>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>java</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<mainClass>cn.cloudowr.dict.Main</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
|
|
@ -95,8 +61,6 @@
|
|||
<groupId>cn.cloudowr</groupId>
|
||||
<artifactId>sdk</artifactId>
|
||||
<version>1.4.16</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/sdk-1.4.16.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -39,7 +39,7 @@ public class ACon extends AbsController{
|
|||
}
|
||||
|
||||
String key = UUID.randomUUID().toString().replace("-", "");
|
||||
UploadFileRequest uploadFileRequest = new UploadFileRequest(Main.BukketName, key);
|
||||
UploadFileRequest uploadFileRequest = new UploadFileRequest(Config.BukketName, key);
|
||||
uploadFileRequest.setUploadFile(file.getUploadPath() + File.separator + file.getFileName());
|
||||
uploadFileRequest.setTaskNum(5);
|
||||
uploadFileRequest.setPartSize(1 * 1024 * 1024);
|
||||
|
|
@ -48,7 +48,7 @@ public class ACon extends AbsController{
|
|||
uploadFileResult.getMultipartUploadResult();
|
||||
|
||||
MongoCollection<Document> collection = getCollection();
|
||||
doc.put("ossurl", Main.OssUrl + key);
|
||||
doc.put("ossurl", Config.OssUrl + key);
|
||||
doc.put("filename", file.getFileName());
|
||||
collection.insertOne(doc);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +1,26 @@
|
|||
package cn.cloudowr.attach;
|
||||
|
||||
|
||||
import cn.cloudowr.sdk.jfinal.ErrorInterceptor;
|
||||
import cn.cloudowr.sdk.jfinal.JQueryParameterFilter;
|
||||
import com.aliyun.oss.OSSClient;
|
||||
import com.jfinal.config.*;
|
||||
import com.jfinal.template.Engine;
|
||||
import com.mongodb.MongoClient;
|
||||
import com.mongodb.MongoClientURI;
|
||||
import com.mongodb.MongoCredential;
|
||||
import com.mongodb.ServerAddress;
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static cn.cloudowr.attach.Main.*;
|
||||
|
||||
/**
|
||||
* Created by lyf66 on 2017/2/17.
|
||||
*/
|
||||
public class Config extends JFinalConfig{
|
||||
|
||||
public static final String AccessKey = "LTAI7tcTTMuROink";
|
||||
public static final String BukketName = "cowr-attach";
|
||||
public static final String OssUrl = "http://cowr-attach.oss-cn-shenzhen.aliyuncs.com/";
|
||||
private static MongoDatabase mongoDatabase;
|
||||
private static OSSClient ossClient;
|
||||
|
||||
|
|
@ -62,9 +63,13 @@ public class Config extends JFinalConfig{
|
|||
}
|
||||
@Override
|
||||
public void afterJFinalStart() {
|
||||
MongoCredential mongoCredential = MongoCredential.createCredential(username, database, password.toCharArray());
|
||||
MongoClient mongoClient = new MongoClient(new ServerAddress(host, port), Arrays.asList(mongoCredential));
|
||||
mongoDatabase = mongoClient.getDatabase(dabaseName);
|
||||
MongoClientURI connectionString = new MongoClientURI("mongodb://root:CoWR1111@dds-wz9ceed1f19591041217-pub.mongodb.rds.aliyuncs.com:3717,dds-wz9ceed1f19591042677-pub.mongodb.rds.aliyuncs.com:3717/admin?replicaSet=mgset-5320915");
|
||||
MongoClient mongoClient = new MongoClient(connectionString);
|
||||
mongoDatabase = mongoClient.getDatabase("dict");
|
||||
|
||||
String endpoint = "oss-cn-shenzhen.aliyuncs.com";
|
||||
String accessKeyId = "LTAI7tcTTMuROink";
|
||||
String accessKeySecret = "qZj94FrKmJF946eHCpNjYtEXKUS0i6";
|
||||
ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
|
||||
}
|
||||
|
||||
|
|
@ -72,6 +77,4 @@ public class Config extends JFinalConfig{
|
|||
public void beforeJFinalStop() {
|
||||
ossClient.shutdown();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package cn.cloudowr.attach;
|
||||
|
||||
import cn.cloudowr.sdk.FastJSONUtil;
|
||||
import cn.cloudowr.sdk.jfinal.IdInterceptor;
|
||||
import cn.cloudowr.sdk.IdInterceptor;
|
||||
import com.aliyun.oss.model.UploadFileRequest;
|
||||
import com.aliyun.oss.model.UploadFileResult;
|
||||
import com.jfinal.aop.Before;
|
||||
|
|
@ -48,7 +48,7 @@ public class Controller extends com.jfinal.core.Controller {
|
|||
}
|
||||
|
||||
String key = UUID.randomUUID().toString().replace("-", "");
|
||||
UploadFileRequest uploadFileRequest = new UploadFileRequest(Main.BukketName, key);
|
||||
UploadFileRequest uploadFileRequest = new UploadFileRequest(Config.BukketName, key);
|
||||
uploadFileRequest.setUploadFile(file.getUploadPath() + File.separator + file.getFileName());
|
||||
uploadFileRequest.setTaskNum(5);
|
||||
uploadFileRequest.setPartSize(1 * 1024 * 1024);
|
||||
|
|
@ -57,7 +57,7 @@ public class Controller extends com.jfinal.core.Controller {
|
|||
uploadFileResult.getMultipartUploadResult();
|
||||
|
||||
MongoCollection<Document> collection = Config.getMongoDatabase().getCollection("attach");
|
||||
doc.put("ossurl", Main.OssUrl + key);
|
||||
doc.put("ossurl", Config.OssUrl + key);
|
||||
doc.put("filename", file.getFileName());
|
||||
collection.insertOne(doc);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,49 +2,11 @@ package cn.cloudowr.attach;
|
|||
|
||||
import com.jfinal.core.JFinal;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Created by lyf66 on 2017/2/16.
|
||||
*/
|
||||
public class Main {
|
||||
public static String username;
|
||||
public static String database;
|
||||
public static String password;
|
||||
public static String host;
|
||||
public static int port;
|
||||
public static String dabaseName;
|
||||
public static String endpoint ;
|
||||
public static String accessKeyId ;
|
||||
public static String accessKeySecret ;
|
||||
public static String BukketName ;
|
||||
public static String OssUrl ;
|
||||
private static int AppPort;
|
||||
|
||||
public static void main(String[] args) {
|
||||
read();
|
||||
JFinal.start("src/main/webapp", AppPort, "/");
|
||||
}
|
||||
|
||||
private static void read(){
|
||||
try{
|
||||
Properties pro = new Properties();
|
||||
pro.load(Config.class.getResourceAsStream("/config.properties"));
|
||||
username = pro.getProperty("username");
|
||||
database = pro.getProperty("database");
|
||||
password = pro.getProperty("password");
|
||||
host = pro.getProperty("host");
|
||||
port = Integer.parseInt(pro.getProperty("port"));
|
||||
dabaseName = pro.getProperty("dabaseName");
|
||||
endpoint = pro.getProperty("endpoint");
|
||||
accessKeyId = pro.getProperty("accessKeyId");
|
||||
accessKeySecret = pro.getProperty("accessKeySecret");
|
||||
BukketName = pro.getProperty("BukketName");
|
||||
OssUrl = pro.getProperty("OssUrl");
|
||||
AppPort = Integer.parseInt(pro.getProperty("AppPort"));
|
||||
}catch ( Exception e ){
|
||||
e.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
JFinal.start("src/main/webapp", 4202, "/");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
username=root
|
||||
database=admin
|
||||
password=CoWR1111
|
||||
host=120.24.5.249
|
||||
port=3717
|
||||
dabaseName=dict
|
||||
accessKeyId=LTAI7tcTTMuROink
|
||||
BukketName=cowr-attach
|
||||
OssUrl=http://cowr-attach.oss-cn-shenzhen.aliyuncs.com/
|
||||
accessKeySecret=qZj94FrKmJF946eHCpNjYtEXKUS0i6
|
||||
endpoint=oss-cn-shenzhen.aliyuncs.com
|
||||
AppPort=4202
|
||||
Loading…
Reference in New Issue