mirror of
https://github.com/cloudreve/Cloudreve.git
synced 2026-11-26 07:24:47 +00:00
Test: filesystem/Preview
This commit is contained in:
1 parent
8a262a15d5
commit
35c2a5c977
4 files changed
+113
-6
No files matched your search
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user