diff --git a/common_test.go b/common_test.go index f05b2b8..4b1c89d 100644 --- a/common_test.go +++ b/common_test.go @@ -29,8 +29,9 @@ func SetupConfig() { CRMConfig = EspoCRMAPIConfig{ "https://c.hitxy.org.au/", "wechat", - "crmwechat.api"} - GlobalPath = PathsConfig{"/tmp", "/tmp"} + "crmwechat.api", + "/tmp/"} + GlobalPath = PathsConfig{"/tmp"} KFUsers.kfRenewList() } diff --git a/configCRM.go b/configCRM.go index d011b77..23d4cd1 100644 --- a/configCRM.go +++ b/configCRM.go @@ -18,6 +18,8 @@ type EspoCRMAPIConfig struct { //access Password UserPass string `json:"UserPass"` + + AttachmentCache string `json:"AttachmentCache"` } //CRMConfig contains secrets that cannot store in source file diff --git a/crm_config.json b/crm_config.json index e9638c3..69f43a4 100644 --- a/crm_config.json +++ b/crm_config.json @@ -1,5 +1,6 @@ { "BaseURL": "https://crm.hitxy.org.au/", "UserName": "wechat", - "UserPass": "crmwechat.api" + "UserPass": "crmwechat.api", + "AttachmentCache" : "/tmp/" } \ No newline at end of file diff --git a/main.go b/main.go index 58f418d..bffa8a5 100644 --- a/main.go +++ b/main.go @@ -10,14 +10,12 @@ import ( //PathsConfig all system available pathes type PathsConfig struct { - CRMAttachment string `json:"crm_attachment"` - Angular2App string `json:"angular2_app"` + Angular2App string `json:"angular2_app"` } //TODO: setup GlobalPath Config, from reading file //GlobalPath all global pathes configurations var GlobalPath = PathsConfig{ - "/tmp/", "/mnt/data/workspace/angular.ts/wechat/ng2-admin/dist/"} //KFUsers info cache about current customer service diff --git a/server.go b/server.go index e2c7083..228b53e 100644 --- a/server.go +++ b/server.go @@ -217,7 +217,7 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) { //in this way, user has no 'direct-access' to the CRM server. func crmAttachmentHandler(w http.ResponseWriter, r *http.Request) { fileID := getCrmFileID(r.URL.Path) - saveAs := GlobalPath.CRMAttachment + "crm_attach_" + fileID //add prefix for easy deleting + saveAs := CRMConfig.AttachmentCache + "crm_attach_" + fileID //add prefix for easy deleting if isFileExist(saveAs) { http.ServeFile(w, r, saveAs) return