|
package model |
|
|
|
import ( |
|
"context" |
|
"io" |
|
"net/http" |
|
"time" |
|
|
|
"github.com/alist-org/alist/v3/pkg/http_range" |
|
"github.com/alist-org/alist/v3/pkg/utils" |
|
) |
|
|
|
type ListArgs struct { |
|
ReqPath string |
|
S3ShowPlaceholder bool |
|
Refresh bool |
|
} |
|
|
|
type LinkArgs struct { |
|
IP string |
|
Header http.Header |
|
Type string |
|
HttpReq *http.Request |
|
} |
|
|
|
type Link struct { |
|
URL string `json:"url"` |
|
Header http.Header `json:"header"` |
|
RangeReadCloser RangeReadCloserIF `json:"-"` |
|
MFile File `json:"-"` |
|
|
|
Expiration *time.Duration |
|
IPCacheKey bool `json:"-"` |
|
|
|
|
|
Concurrency int `json:"concurrency"` |
|
PartSize int `json:"part_size"` |
|
} |
|
|
|
type OtherArgs struct { |
|
Obj Obj |
|
Method string |
|
Data interface{} |
|
} |
|
|
|
type FsOtherArgs struct { |
|
Path string `json:"path" form:"path"` |
|
Method string `json:"method" form:"method"` |
|
Data interface{} `json:"data" form:"data"` |
|
} |
|
type RangeReadCloserIF interface { |
|
RangeRead(ctx context.Context, httpRange http_range.Range) (io.ReadCloser, error) |
|
utils.ClosersIF |
|
} |
|
|
|
var _ RangeReadCloserIF = (*RangeReadCloser)(nil) |
|
|
|
type RangeReadCloser struct { |
|
RangeReader RangeReaderFunc |
|
utils.Closers |
|
} |
|
|
|
func (r RangeReadCloser) RangeRead(ctx context.Context, httpRange http_range.Range) (io.ReadCloser, error) { |
|
rc, err := r.RangeReader(ctx, httpRange) |
|
r.Closers.Add(rc) |
|
return rc, err |
|
} |
|
|
|
|
|
type RangeReaderFunc func(ctx context.Context, httpRange http_range.Range) (io.ReadCloser, error) |
|
|