feat: 实现多部分上传功能,支持初始化、上传部分、完成和中止上传,添加媒体资产删除功能
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -39,6 +41,19 @@ type Storage struct {
|
||||
Config *Config
|
||||
}
|
||||
|
||||
func (s *Storage) Delete(key string) error {
|
||||
if s.Config.Type == "local" {
|
||||
localPath := s.Config.LocalPath
|
||||
if localPath == "" {
|
||||
localPath = "./storage"
|
||||
}
|
||||
path := filepath.Join(localPath, key)
|
||||
return os.Remove(path)
|
||||
}
|
||||
// TODO: S3 implementation
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Storage) SignURL(method, key string, expires time.Duration) (string, error) {
|
||||
exp := time.Now().Add(expires).Unix()
|
||||
sign := s.signature(method, key, exp)
|
||||
|
||||
Reference in New Issue
Block a user