mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-01 22:02:46 +00:00
Pass a context when downloading remote media (#251)
This commit is contained in:
parent
fef290c47e
commit
ce019738ff
6 changed files with 65 additions and 20 deletions
|
@ -236,9 +236,15 @@ func (fc *Client) LookupServerKeys( // nolint: gocyclo
|
|||
}
|
||||
|
||||
// CreateMediaDownloadRequest creates a request for media on a homeserver and returns the http.Response or an error
|
||||
func (fc *Client) CreateMediaDownloadRequest(matrixServer ServerName, mediaID string) (*http.Response, error) {
|
||||
func (fc *Client) CreateMediaDownloadRequest(
|
||||
ctx context.Context, matrixServer ServerName, mediaID string,
|
||||
) (*http.Response, error) {
|
||||
requestURL := "matrix://" + string(matrixServer) + "/_matrix/media/v1/download/" + string(matrixServer) + "/" + mediaID
|
||||
resp, err := fc.client.Get(requestURL)
|
||||
req, err := http.NewRequest("GET", requestURL, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := fc.client.Do(req.WithContext(ctx))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue