feat: 完成了 新建桶; 上传文件(基本功能)

todo: 上传 rename, 上传 public 权限选择
bug: 首次加载 conns list; 上传的时候前缀过滤失败
This commit is contained in:
zhaoyupeng
2024-10-12 17:35:59 +08:00
parent 1c818daf16
commit 777253063b
28 changed files with 791 additions and 96 deletions

32
internal/tool/slice.go Normal file
View File

@ -0,0 +1,32 @@
package tool
import "iter"
func Bulk[T any](slice []T, size int) iter.Seq2[int, []T] {
if size <= 0 {
panic("bulk size must be positive")
}
s := make([]T, 0, size)
idx := 0
return func(yield func(int, []T) bool) {
for i := range slice {
s = append(s, (slice)[i])
if len(s) >= size {
// send to handle
ok := yield(idx, s)
if !ok {
return
}
idx++
s = make([]T, 0, size)
}
}
if len(s) > 0 {
yield(idx, s)
}
}
}