mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: download / preview files for shared folder
This commit is contained in:
@@ -133,6 +133,11 @@ func (service *SingleFileService) CreateDocPreviewSession(ctx context.Context, c
|
||||
fs.SetTargetFile(&[]model.File{*file})
|
||||
}
|
||||
|
||||
// 如果上下文中已有Folder对象,则重设目标
|
||||
if folder, ok := ctx.Value(fsctx.FolderModelCtx).(*model.Folder); ok {
|
||||
fs.SetTargetDir(&[]model.Folder{*folder})
|
||||
}
|
||||
|
||||
// 获取文件临时下载地址
|
||||
downloadURL, err := fs.GetDownloadURL(ctx, service.Path, "doc_preview_timeout")
|
||||
if err != nil {
|
||||
@@ -228,6 +233,11 @@ func (service *SingleFileService) PreviewContent(ctx context.Context, c *gin.Con
|
||||
fs.SetTargetFile(&[]model.File{*file})
|
||||
}
|
||||
|
||||
// 如果上下文中已有Folder对象,则重设目标
|
||||
if folder, ok := ctx.Value(fsctx.FolderModelCtx).(*model.Folder); ok {
|
||||
fs.SetTargetDir(&[]model.Folder{*folder})
|
||||
}
|
||||
|
||||
// 获取文件预览响应
|
||||
resp, err := fs.Preview(ctx, service.Path, isText)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user