forked from hugozhu/godingtalk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_file.go
38 lines (33 loc) · 774 Bytes
/
api_file.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package godingtalk
import (
"bytes"
"fmt"
"io"
"net/url"
)
/**
* https://open-doc.dingtalk.com/docs/doc.htm?spm=a219a.7629140.0.0.UeYQVr&treeId=172&articleId=104970&docType=1
* TODO: not completed yet
**/
//FileResponse is
type FileResponse struct {
OAPIResponse
Code int
Msg string
UploadID string `json:"uploadid"`
Writer io.Writer
}
func (f *FileResponse) getWriter() io.Writer {
return f.Writer
}
//CreateFile is to create a new file in Ding Space
func (c *DingTalkClient) CreateFile(size int64) (file FileResponse, err error) {
buf := bytes.Buffer{}
file = FileResponse{
Writer: &buf,
}
params := url.Values{}
params.Add("size", fmt.Sprintf("%d", size))
err = c.httpRPC("file/upload/create", params, nil, &file)
return file, err
}