diff --git a/crmAttachment.go b/crmAttachment.go index 961d3fd..cc86769 100644 --- a/crmAttachment.go +++ b/crmAttachment.go @@ -52,12 +52,15 @@ func crmPrepareAttachmentHTTPHeader(fileInfo crmFileInfo) (headers map[string]st } func crmUploadAttachmentURL() string { - return "https://c.hitxy.org.au/api/v1/Attachment/action/upload" + + return CRMConfig.BaseURL + "api/v1/Attachment/action/upload" } func crmAuthHeader() string { //return "Basic cGF0cmljazpiNjFmYWRlMTM5OWYwY2ZjNmZjZjcxNTU0OTljNTNkOQ==" - return "Basic cGF0cmljazp3b3JraGFyZA==" + s := CRMConfig.UserName + ":" + CRMConfig.UserPass + r := base64.StdEncoding.EncodeToString([]byte(s)) + return "Basic " + r } //crmFileDataString, encode a base64 string of the given file @@ -93,7 +96,8 @@ func crmUploadAttachmentMeta(fileID string, fileInfo crmFileInfo) (resp string, } func crmAttachmentMetaURL(fileID string) string { - return "https://c.hitxy.org.au/api/v1/Attachment/" + fileID + //return "https://c.hitxy.org.au/api/v1/Attachment/" + fileID + return CRMConfig.BaseURL + "api/v1/Attachment/" + fileID } type attachmentInfo struct { diff --git a/crmAttachment_test.go b/crmAttachment_test.go index a47f3cb..1efc3c5 100644 --- a/crmAttachment_test.go +++ b/crmAttachment_test.go @@ -5,6 +5,7 @@ import "log" import "encoding/json" func TestCRMAttachFile(t *testing.T) { + SetupConfig() r, e := crmCreateAttachment("media_for_test/200x200.png") log.Println(r) log.Println(e)