From fea6efb20cfd311968d672dd58887b1ee3d89008 Mon Sep 17 00:00:00 2001 From: frank Date: Tue, 15 Mar 2022 16:06:18 +0800 Subject: [PATCH] expand Asana attach method for aes256 decryption --- module/attach/attachments.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/module/attach/attachments.go b/module/attach/attachments.go index 3746c23..b0e8868 100644 --- a/module/attach/attachments.go +++ b/module/attach/attachments.go @@ -17,10 +17,6 @@ import ( "git.drinkme.beer/yinghe/asana/util" ) -const ( - URI = "/api/1.0/tasks/%s/attachments" -) - type Request struct { Body io.Reader TaskID string @@ -48,8 +44,16 @@ func escapeQuotes(s string) string { return quoteEscaper.Replace(s) } +func (r Request) CreateInEncryption(download func(src, tmp string) error) (*Response, error) { + return r.create(download) +} + // Create - upload attachments func (r Request) Create() (resp *Response, err error) { + return r.create(download) +} + +func (r Request) create(f func(src, tmp string) error) (resp *Response, err error) { var ( tempPath string data struct { @@ -59,7 +63,7 @@ func (r Request) Create() (resp *Response, err error) { tempPath = "./static/" + r.Name // TODO - err = download(r.Path, tempPath) + err = f(r.Path, tempPath) if nil != err { return nil, err }