mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[feature] S3: add config flag to proxy S3 media (#1014)
* S3: add config value "proxy" for not redirecting Signed-off-by: Mara Sophie Grosch <littlefox@lf-net.org> * S3: document new config value "proxy" * S3: add new config value "proxy" to test scripts Signed-off-by: Mara Sophie Grosch <littlefox@lf-net.org>
This commit is contained in:
committed by
GitHub
parent
3ce0e33f99
commit
948e90b95a
@ -34,12 +34,14 @@ import (
|
||||
type S3 struct {
|
||||
mc *minio.Client
|
||||
bucket string
|
||||
proxy bool
|
||||
}
|
||||
|
||||
func NewS3(mc *minio.Client, bucket string) *S3 {
|
||||
func NewS3(mc *minio.Client, bucket string, proxy bool) *S3 {
|
||||
return &S3{
|
||||
mc: mc,
|
||||
bucket: bucket,
|
||||
proxy: proxy,
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,6 +85,10 @@ func (s *S3) Delete(ctx context.Context, key string) error {
|
||||
}
|
||||
|
||||
func (s *S3) URL(ctx context.Context, key string) *url.URL {
|
||||
if s.proxy {
|
||||
return nil
|
||||
}
|
||||
|
||||
// it's safe to ignore the error here, as we just fall back to fetching the
|
||||
// file if the url request fails
|
||||
url, _ := s.mc.PresignedGetObject(ctx, s.bucket, key, time.Hour, url.Values{
|
||||
|
Reference in New Issue
Block a user