(ctx context.Context, realPath string)
| 120 | } |
| 121 | |
| 122 | func (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 | |
| 153 | func (d *Strm) linkRealFile(ctx context.Context, realPath string, args model.LinkArgs) (*model.Link, error) { |
| 154 | storage, actualPath, err := op.GetStorageAndActualPath(realPath) |
no test coverage detected