Ver código fonte

CRM attachment now using global config

master
Patrick Peng Sun 8 anos atrás
pai
commit
e3783bb365
2 arquivos alterados com 8 adições e 3 exclusões
  1. +7
    -3
      crmAttachment.go
  2. +1
    -0
      crmAttachment_test.go

+ 7
- 3
crmAttachment.go Ver arquivo

@@ -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 {

+ 1
- 0
crmAttachment_test.go Ver arquivo

@@ -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)

Carregando…
Cancelar
Salvar