Test: filesystem/Preview

This commit is contained in:
HFO4
2019-12-31 13:31:20 +08:00
parent 8a262a15d5
commit 35c2a5c977
4 changed files with 113 additions and 6 deletions

View File

@@ -88,7 +88,6 @@ func (fs *FileSystem) GetPhysicalFileContent(ctx context.Context, path string) (
}
// Preview 预览文件
// TODO 测试
func (fs *FileSystem) Preview(ctx context.Context, path string) (*response.ContentResponse, error) {
err := fs.resetFileIfNotExist(ctx, path)
if err != nil {
@@ -106,6 +105,7 @@ func (fs *FileSystem) Preview(ctx context.Context, path string) (*response.Conte
Content: resp,
}, nil
}
// 否则重定向到签名的预览URL
ttl, err := strconv.ParseInt(model.GetSettingByName("preview_timeout"), 10, 64)
if err != nil {
@@ -116,12 +116,10 @@ func (fs *FileSystem) Preview(ctx context.Context, path string) (*response.Conte
err,
)
}
previewURL, err := fs.signURL(ctx, &fs.FileTarget[0], ttl, false)
if err != nil {
return nil, err
}
return &response.ContentResponse{
Redirect: true,
URL: previewURL,