17 type FileTransfer struct {
20 ReferenceNumber []byte
22 TransferSize []byte // total size of all items in the folder. Only used in FolderUpload action
23 FolderItemCount []byte
28 func (ft *FileTransfer) String() string {
30 out := fmt.Sprintf("%s\t %v", ft.FileName, percentComplete)
37 // 00 02 // PathItemCount
41 // 73 75 62 66 6f 6c 64 65 72 // "subfolder"
45 // 73 75 62 66 6f 6c 64 65 72 2d 74 65 73 74 66 69 6c 65 2d 35 6b // "subfolder-testfile-5k"
46 func readFolderUpload(buf []byte) folderUpload {
47 dataLen := binary.BigEndian.Uint16(buf[0:2])
50 DataSize: [2]byte{buf[0], buf[1]}, // Size of this structure (not including data size element itself)
51 IsFolder: [2]byte{buf[2], buf[3]},
52 PathItemCount: [2]byte{buf[4], buf[5]},
53 FileNamePath: buf[6 : dataLen+2],
60 func (fu *folderUpload) UnmarshalBinary(b []byte) error {
61 fu.DataSize = [2]byte{b[0], b[1]}
62 fu.IsFolder = [2]byte{b[2], b[3]}
63 fu.PathItemCount = [2]byte{b[4], b[5]}
68 type folderUpload struct {
75 func (fu *folderUpload) FormattedPath() string {
76 pathItemLen := binary.BigEndian.Uint16(fu.PathItemCount[:])
78 var pathSegments []string
79 pathData := fu.FileNamePath
81 for i := uint16(0); i < pathItemLen; i++ {
83 pathSegments = append(pathSegments, string(pathData[3:3+segLen]))
84 pathData = pathData[3+segLen:]
87 return strings.Join(pathSegments, pathSeparator)