Skip to content

Commit

Permalink
Fix: doc preview src of local storage policy starts with ":/" (#1842) (
Browse files Browse the repository at this point in the history
…#1844)

* Fix: doc preview src of local storage policy starts with ":/"

* Fix: doc preview src of local storage policy starts with ":/"
  • Loading branch information
YUDONGLING authored Oct 6, 2023
1 parent 3ffce1e commit cd6eee0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion service/explorer/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,14 @@ func (service *FileIDService) CreateDocPreviewSession(ctx context.Context, c *gi
return serializer.Err(serializer.CodeNotSet, err.Error(), err)
}

// For newer version of Cloudreve - Local Policy
// When do not use a cdn, the downloadURL withouts hosts, like "/api/v3/file/download/xxx"
if strings.HasPrefix(downloadURL, "/") {
downloadURL = path.Join(model.GetSiteURL().String(), downloadURL)
downloadURI, err := url.Parse(downloadURL)
if err != nil {
return serializer.Err(serializer.CodeNotSet, err.Error(), err)
}
downloadURL = model.GetSiteURL().ResolveReference(downloadURI).String()
}

var resp serializer.DocPreviewSession
Expand Down

0 comments on commit cd6eee0

Please sign in to comment.