@@ -14,6 +14,7 @@ import (
14
14
"github.com/OpenListTeam/OpenList/internal/model"
15
15
"github.com/OpenListTeam/OpenList/internal/stream"
16
16
"github.com/OpenListTeam/OpenList/pkg/cron"
17
+ "github.com/OpenListTeam/OpenList/pkg/utils"
17
18
"github.com/OpenListTeam/OpenList/server/common"
18
19
"github.com/aws/aws-sdk-go/aws/session"
19
20
"github.com/aws/aws-sdk-go/service/s3"
@@ -81,19 +82,21 @@ func (d *S3) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]mo
81
82
82
83
func (d * S3 ) Link (ctx context.Context , file model.Obj , args model.LinkArgs ) (* model.Link , error ) {
83
84
path := getKey (file .GetPath (), false )
84
- filename := stdpath .Base (path )
85
- disposition := fmt .Sprintf (`attachment; filename*=UTF-8''%s` , url .PathEscape (filename ))
86
- if d .AddFilenameToDisposition {
87
- disposition = fmt .Sprintf (`attachment; filename="%s"; filename*=UTF-8''%s` , filename , url .PathEscape (filename ))
88
- }
85
+ fileName := stdpath .Base (path )
89
86
input := & s3.GetObjectInput {
90
87
Bucket : & d .Bucket ,
91
88
Key : & path ,
92
89
//ResponseContentDisposition: &disposition,
93
90
}
91
+
94
92
if d .CustomHost == "" {
93
+ disposition := fmt .Sprintf (`attachment; filename*=UTF-8''%s` , url .PathEscape (fileName ))
94
+ if d .AddFilenameToDisposition {
95
+ disposition = utils .GenerateContentDisposition (fileName )
96
+ }
95
97
input .ResponseContentDisposition = & disposition
96
98
}
99
+
97
100
req , _ := d .linkClient .GetObjectRequest (input )
98
101
var link model.Link
99
102
var err error
@@ -108,7 +111,7 @@ func (d *S3) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*mo
108
111
link .URL = strings .Replace (link .URL , "/" + d .Bucket , "" , 1 )
109
112
}
110
113
} else {
111
- if common .ShouldProxy (d , filename ) {
114
+ if common .ShouldProxy (d , fileName ) {
112
115
err = req .Sign ()
113
116
link .URL = req .HTTPRequest .URL .String ()
114
117
link .Header = req .HTTPRequest .Header
0 commit comments