-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattachment.go
40 lines (32 loc) · 1.13 KB
/
attachment.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
39
40
package docs
import (
"io"
"github.com/go-lark/docs/doctypes"
)
/*
for update a file or image in a doc
*/
const (
attachmentUpdateAllURL = "/open-apis/drive/v1/medias/upload_all"
attachmentUpdateResumePrepare = "/open-apis/drive/v1/medias/upload_prepare"
attachmentUpdateResumePart = "/open-apis/drive/v1/medias/upload_part"
attachmentUpdateResumeFinish = "/open-apis/drive/v1/medias/upload_finish"
)
func newAttachment(client *Client) *Attachment {
return &Attachment{
f: newFile(client),
}
}
type Attachment struct {
f *File
}
func (a *Attachment) UpdateAll(attachmentType doctypes.AttachmentType, token, filename string, fileData []byte) (string, error) {
return a.f.updateAllBase(attachmentUpdateAllURL, attachmentType, token, filename, fileData)
}
func (a *Attachment) UpdateResuming(attachmentType doctypes.AttachmentType, token, filename string, fileSize int64, fileData io.Reader, processChan chan int64) (string, error) {
return a.f.updateResumeBase(
attachmentUpdateResumePrepare, attachmentUpdateResumePart, attachmentUpdateResumeFinish,
attachmentType, token, filename,
fileSize, fileData, processChan,
)
}