|
@ -17,10 +17,6 @@ import ( |
|
|
"git.drinkme.beer/yinghe/asana/util" |
|
|
"git.drinkme.beer/yinghe/asana/util" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
const ( |
|
|
|
|
|
URI = "/api/1.0/tasks/%s/attachments" |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
type Request struct { |
|
|
type Request struct { |
|
|
Body io.Reader |
|
|
Body io.Reader |
|
|
TaskID string |
|
|
TaskID string |
|
@ -48,8 +44,16 @@ func escapeQuotes(s string) string { |
|
|
return quoteEscaper.Replace(s) |
|
|
return quoteEscaper.Replace(s) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (r Request) CreateInEncryption(download func(src, tmp string) error) (*Response, error) { |
|
|
|
|
|
return r.create(download) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Create - upload attachments
|
|
|
// Create - upload attachments
|
|
|
func (r Request) Create() (resp *Response, err error) { |
|
|
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 ( |
|
|
var ( |
|
|
tempPath string |
|
|
tempPath string |
|
|
data struct { |
|
|
data struct { |
|
@ -59,7 +63,7 @@ func (r Request) Create() (resp *Response, err error) { |
|
|
tempPath = "./static/" + r.Name |
|
|
tempPath = "./static/" + r.Name |
|
|
|
|
|
|
|
|
// TODO
|
|
|
// TODO
|
|
|
err = download(r.Path, tempPath) |
|
|
|
|
|
|
|
|
err = f(r.Path, tempPath) |
|
|
if nil != err { |
|
|
if nil != err { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|