mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-11-25 11:29:29 +08:00
Compare commits
2 Commits
renovate/g
...
in-browser
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
749fc07cb2 | ||
|
|
18173878c4 |
1
go.mod
1
go.mod
@@ -16,7 +16,6 @@ require (
|
||||
github.com/avast/retry-go v3.0.0+incompatible
|
||||
github.com/aws/aws-sdk-go v1.55.7
|
||||
github.com/blevesearch/bleve/v2 v2.5.2
|
||||
github.com/caarlos0/env/v11 v11.3.1
|
||||
github.com/caarlos0/env/v9 v9.0.0
|
||||
github.com/charmbracelet/bubbles v0.21.0
|
||||
github.com/charmbracelet/bubbletea v1.3.6
|
||||
|
||||
1
go.sum
1
go.sum
@@ -169,7 +169,6 @@ github.com/bytedance/sonic v1.13.3/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1
|
||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||
github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY=
|
||||
github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
||||
github.com/caarlos0/env/v11 v11.3.1/go.mod h1:qupehSf/Y0TUTsxKywqRt/vJjN5nz6vauiYEUUr8P4U=
|
||||
github.com/caarlos0/env/v9 v9.0.0 h1:SI6JNsOA+y5gj9njpgybykATIylrRMklbs5ch6wO6pc=
|
||||
github.com/caarlos0/env/v9 v9.0.0/go.mod h1:ye5mlCVMYh6tZ+vCgrs/B95sj88cg5Tlnc0XIzgZ020=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
|
||||
@@ -132,7 +132,8 @@ func InitialSettings() []model.SettingItem {
|
||||
"Google":"https://docs.google.com/gview?url=$e_url&embedded=true"
|
||||
},
|
||||
"pdf": {
|
||||
"PDF.js":"https://res.oplist.org/pdf.js/web/viewer.html?file=$e_url"
|
||||
"PDF.js":"https://res.oplist.org/pdf.js/web/viewer.html?file=$e_url",
|
||||
"Browser":"$url?inline_preview=true"
|
||||
},
|
||||
"epub": {
|
||||
"EPUB.js":"https://res.oplist.org/epub.js/viewer.html?url=$e_url"
|
||||
|
||||
@@ -18,14 +18,18 @@ import (
|
||||
)
|
||||
|
||||
func Proxy(w http.ResponseWriter, r *http.Request, link *model.Link, file model.Obj) error {
|
||||
|
||||
// check if query param "inline_preview" is true
|
||||
inlinePreview := r.URL.Query().Get("inline_preview") == "true"
|
||||
|
||||
if link.MFile != nil {
|
||||
attachHeader(w, file, link)
|
||||
attachHeader(w, file, link, inlinePreview)
|
||||
http.ServeContent(w, r, file.GetName(), file.ModTime(), link.MFile)
|
||||
return nil
|
||||
}
|
||||
|
||||
if link.Concurrency > 0 || link.PartSize > 0 {
|
||||
attachHeader(w, file, link)
|
||||
attachHeader(w, file, link, inlinePreview)
|
||||
size := link.ContentLength
|
||||
if size <= 0 {
|
||||
size = file.GetSize()
|
||||
@@ -40,7 +44,7 @@ func Proxy(w http.ResponseWriter, r *http.Request, link *model.Link, file model.
|
||||
}
|
||||
|
||||
if link.RangeReader != nil {
|
||||
attachHeader(w, file, link)
|
||||
attachHeader(w, file, link, inlinePreview)
|
||||
size := link.ContentLength
|
||||
if size <= 0 {
|
||||
size = file.GetSize()
|
||||
@@ -70,9 +74,11 @@ func Proxy(w http.ResponseWriter, r *http.Request, link *model.Link, file model.
|
||||
})
|
||||
return err
|
||||
}
|
||||
func attachHeader(w http.ResponseWriter, file model.Obj, link *model.Link) {
|
||||
func attachHeader(w http.ResponseWriter, file model.Obj, link *model.Link, inlinePreview bool) {
|
||||
fileName := file.GetName()
|
||||
w.Header().Set("Content-Disposition", utils.GenerateContentDisposition(fileName))
|
||||
if !inlinePreview {
|
||||
w.Header().Set("Content-Disposition", utils.GenerateContentDisposition(fileName))
|
||||
}
|
||||
w.Header().Set("Content-Type", utils.GetMimeType(fileName))
|
||||
size := link.ContentLength
|
||||
if size <= 0 {
|
||||
|
||||
Reference in New Issue
Block a user