-
Notifications
You must be signed in to change notification settings - Fork 12
/
manager_file.go
66 lines (63 loc) · 1.22 KB
/
manager_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package mtproto
import (
"log"
"reflect"
)
func (m *MTProto) Upload_GetFile(in TL, offset, limit int32) []byte {
resp := make(chan TL, 1)
m.queueSend <- packetToSend{
TL_upload_getFile{
Offset: offset,
Limit: limit,
Location: in,
},
resp,
}
x := <-resp
switch f := x.(type) {
case TL_upload_file:
return f.Bytes
case TL_upload_fileCdnRedirect:
case TL_rpc_error:
if f.error_code == 303 {
// Migrate Code
}
default:
log.Println(reflect.TypeOf(f).String(), f)
}
return []byte{}
}
func (m *MTProto) Upload_GetCdnFile(fileToken []byte, offset, limit int32) []byte {
resp := make(chan TL, 1)
m.queueSend <- packetToSend{
TL_upload_getCdnFile{
fileToken,
offset,
limit,
},
resp,
}
x := <-resp
switch f := x.(type) {
case TL_upload_cdnFileReuploadNeeded:
m.queueSend <- packetToSend{
TL_upload_reuploadCdnFile{
Request_token: f.Request_token,
File_token: fileToken,
},
resp,
}
z := <-resp
switch reflect.TypeOf(z).Kind() {
case reflect.Slice:
s := reflect.ValueOf(z)
for i := 0; i < s.Len(); i++ {
//hash := s.Interface().(TL_cdnFileHash)
//TODO:: what to do now ?!!
}
}
case TL_upload_cdnFile:
return f.Bytes
}
return []byte{}
}