init: 0.1.0
feat: 基本功能有了 1. 分片上传 2. code 回显 3. 下载 todo: 断点上传
This commit is contained in:
@ -40,11 +40,11 @@ var (
|
||||
MetaManager = &meta{m: make(map[string]*metaInfo)}
|
||||
)
|
||||
|
||||
const letters = "1234567890abcdefghijklmnopqrstuvwxyz"
|
||||
const letters = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
func (m *meta) New(size int64, filename, ip string) (string, error) {
|
||||
now := time.Now()
|
||||
code, err := gonanoid.Generate(letters, 16)
|
||||
code, err := gonanoid.Generate(letters, opt.CodeLength)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ func ShareUpload() nf.HandlerFunc {
|
||||
rangeValidator := regexp.MustCompile(`^bytes=\d+-\d+$`)
|
||||
return func(c *nf.Ctx) error {
|
||||
code := strings.TrimSpace(c.Param("code"))
|
||||
if len(code) != 16 {
|
||||
if len(code) != opt.CodeLength {
|
||||
return c.Status(http.StatusBadRequest).JSON(map[string]string{"msg": "invalid file code"})
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import "path/filepath"
|
||||
const (
|
||||
Meta = ".meta."
|
||||
HeaderSize = "X-File-Size"
|
||||
CodeLength = 8
|
||||
)
|
||||
|
||||
func FilePath(code string) string {
|
||||
|
Reference in New Issue
Block a user