MCPcopy
hub / github.com/AlistGo/alist / buildStrmLine

Method buildStrmLine

drivers/strm/util.go:122–151  ·  view source on GitHub ↗
(ctx context.Context, realPath string)

Source from the content-addressed store, hash-verified

120}
121
122func (d *Strm) buildStrmLine(ctx context.Context, realPath string) string {
123 pathPart := realPath
124 if d.EncodePath {
125 pathPart = utils.EncodePath(pathPart, true)
126 }
127 if d.WithSign {
128 sep := "?"
129 if strings.Contains(pathPart, "?") {
130 sep = "&"
131 }
132 pathPart += sep + "sign=" + d.generateSign(realPath)
133 }
134 joined := stdpath.Join(d.normalizedPrefix, pathPart)
135 if !strings.HasPrefix(joined, "/") {
136 joined = "/" + joined
137 }
138 if d.WithoutUrl {
139 return joined
140 }
141 baseURL := strings.TrimSpace(d.SiteUrl)
142 if baseURL == "" {
143 if c, ok := ctx.(*gin.Context); ok {
144 baseURL = common.GetApiUrl(c.Request)
145 } else {
146 baseURL = common.GetApiUrl(nil)
147 }
148 }
149 baseURL = strings.TrimSuffix(baseURL, "/")
150 return baseURL + joined
151}
152
153func (d *Strm) linkRealFile(ctx context.Context, realPath string, args model.LinkArgs) (*model.Link, error) {
154 storage, actualPath, err := op.GetStorageAndActualPath(realPath)

Callers 3

LinkMethod · 0.95
mapListedObjectsMethod · 0.95
localPayloadMethod · 0.95

Calls 4

generateSignMethod · 0.95
EncodePathFunction · 0.92
GetApiUrlFunction · 0.92
ContainsMethod · 0.80

Tested by

no test coverage detected