|
|
@ -149,7 +149,7 @@ func (fs *FileSystem) CancelUpload(ctx context.Context, path string, file fsctx.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// CreateUploadSession 创建上传会话
|
|
|
|
// CreateUploadSession 创建上传会话
|
|
|
|
func (fs *FileSystem) CreateUploadSession(ctx context.Context, path string, size uint64, name string) (*serializer.UploadCredential, error) {
|
|
|
|
func (fs *FileSystem) CreateUploadSession(ctx context.Context, file *fsctx.FileStream) (*serializer.UploadCredential, error) {
|
|
|
|
// 获取相关有效期设置
|
|
|
|
// 获取相关有效期设置
|
|
|
|
credentialTTL := model.GetIntSetting("upload_credential_timeout", 3600)
|
|
|
|
credentialTTL := model.GetIntSetting("upload_credential_timeout", 3600)
|
|
|
|
callBackSessionTTL := model.GetIntSetting("upload_session_timeout", 86400)
|
|
|
|
callBackSessionTTL := model.GetIntSetting("upload_session_timeout", 86400)
|
|
|
@ -157,16 +157,12 @@ func (fs *FileSystem) CreateUploadSession(ctx context.Context, path string, size
|
|
|
|
callbackKey := uuid.Must(uuid.NewV4()).String()
|
|
|
|
callbackKey := uuid.Must(uuid.NewV4()).String()
|
|
|
|
|
|
|
|
|
|
|
|
// 创建隐藏的文件,同时校验文件信息
|
|
|
|
// 创建隐藏的文件,同时校验文件信息
|
|
|
|
file := &fsctx.FileStream{
|
|
|
|
file.Mode = fsctx.Nop
|
|
|
|
Size: size,
|
|
|
|
file.Hidden = true
|
|
|
|
Name: name,
|
|
|
|
file.Metadata = map[string]string{
|
|
|
|
VirtualPath: path,
|
|
|
|
|
|
|
|
Mode: fsctx.Nop,
|
|
|
|
|
|
|
|
Hidden: true,
|
|
|
|
|
|
|
|
Metadata: map[string]string{
|
|
|
|
|
|
|
|
UploadSessionMetaKey: callbackKey,
|
|
|
|
UploadSessionMetaKey: callbackKey,
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fs.Use("BeforeUpload", HookValidateFile)
|
|
|
|
fs.Use("BeforeUpload", HookValidateFile)
|
|
|
|
fs.Use("AfterUpload", HookClearFileHeaderSize)
|
|
|
|
fs.Use("AfterUpload", HookClearFileHeaderSize)
|
|
|
|
fs.Use("AfterUpload", GenericAfterUpload)
|
|
|
|
fs.Use("AfterUpload", GenericAfterUpload)
|
|
|
@ -178,11 +174,12 @@ func (fs *FileSystem) CreateUploadSession(ctx context.Context, path string, size
|
|
|
|
Key: callbackKey,
|
|
|
|
Key: callbackKey,
|
|
|
|
UID: fs.User.ID,
|
|
|
|
UID: fs.User.ID,
|
|
|
|
PolicyID: fs.Policy.ID,
|
|
|
|
PolicyID: fs.Policy.ID,
|
|
|
|
VirtualPath: path,
|
|
|
|
VirtualPath: file.VirtualPath,
|
|
|
|
Name: name,
|
|
|
|
Name: file.Name,
|
|
|
|
Size: size,
|
|
|
|
Size: file.Size,
|
|
|
|
SavePath: file.SavePath,
|
|
|
|
SavePath: file.SavePath,
|
|
|
|
ChunkSize: fs.Policy.OptionsSerialized.ChunkSize,
|
|
|
|
ChunkSize: fs.Policy.OptionsSerialized.ChunkSize,
|
|
|
|
|
|
|
|
LastModified: file.GetLastModified(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取上传凭证
|
|
|
|
// 获取上传凭证
|
|
|
|