Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Attachements Finalized
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldcanady committed Oct 12, 2021
1 parent bc63cce commit 4c4c187
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion SnowRequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ func (S SnowRequest) _get_response(method string, stream bool, header map[string
}

payload := grequests.RequestOptions{
JSON: jsonString,
JSON: jsonString,
Headers: header,
}

switch method {
Expand Down
6 changes: 3 additions & 3 deletions attachments.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Attachment struct {
func NewAttachment(resource Resource, tableName string) (A Attachment) {
A.resource = resource
A.tableName = tableName
return
}

func (A Attachment) Get(sys_id string, limit int) (Response, error) {
Expand All @@ -31,7 +32,7 @@ func (A Attachment) Upload(sys_id, file_path string, multipart bool) (Response,
resource := A.resource
name := filepath.Base(file_path)
resource.Parameters.AddCustom(map[string]interface{}{"table_name": A.tableName, "table_sys_id": sys_id, "file_name": name})
data, _ = os.ReadFile(file_path)
data, _ := os.ReadFile(file_path)

headers := map[string]string{}
var path_append string
Expand All @@ -48,9 +49,8 @@ func (A Attachment) Upload(sys_id, file_path string, multipart bool) (Response,
headers["Content-Type"] = ("text/plain")
}
path_append = "/file"

return resource.request("POST", path_append, headers, map[string]string{})
}
return resource.request("POST", data, path_append, headers, map[string]string{})
}

func (A Attachment) Delete(sys_id string) (map[string]interface{}, error) {
Expand Down
3 changes: 2 additions & 1 deletion resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ func (R Resource) _request() SnowRequest {
return SnowRequestNew(R.Parameters, R.Session, R.Url_builder, 0, R)
}

func (R Resource) request(method string, path_append string, headers map[string]string, args map[string]string) (Response, error) {
func (R Resource) request(method string, data []byte, path_append string, headers map[string]string, args map[string]string) (Response, error) {
//TODO add parameter for data
return R._request().custom(method, path_append, headers, args)
}

Expand Down

0 comments on commit 4c4c187

Please sign in to comment.