@@ -279,15 +279,20 @@ func (m *MinioStorage) Delete(path string) error {
279279}
280280
281281// URL gets the redirect URL to a file. The presigned link is valid for 5 minutes.
282- func (m * MinioStorage ) URL (path , name string , serveDirectReqParams url.Values ) (* url.URL , error ) {
282+ func (m * MinioStorage ) URL (path , name , method string , serveDirectReqParams url.Values ) (* url.URL , error ) {
283283 // copy serveDirectReqParams
284284 reqParams , err := url .ParseQuery (serveDirectReqParams .Encode ())
285285 if err != nil {
286286 return nil , err
287287 }
288288 // TODO it may be good to embed images with 'inline' like ServeData does, but we don't want to have to read the file, do we?
289289 reqParams .Set ("response-content-disposition" , "attachment; filename=\" " + quoteEscaper .Replace (name )+ "\" " )
290- u , err := m .client .PresignedGetObject (m .ctx , m .bucket , m .buildMinioPath (path ), 5 * time .Minute , reqParams )
290+ expires := 5 * time .Minute
291+ if method == http .MethodHead {
292+ u , err := m .client .PresignedHeadObject (m .ctx , m .bucket , m .buildMinioPath (path ), expires , reqParams )
293+ return u , convertMinioErr (err )
294+ }
295+ u , err := m .client .PresignedGetObject (m .ctx , m .bucket , m .buildMinioPath (path ), expires , reqParams )
291296 return u , convertMinioErr (err )
292297}
293298
0 commit comments