getObject: Add support for special response headers.

Supports now response-content-type, response-content-disposition,
response-cache-control, response-expires.
This commit is contained in:
Harshavardhana
2016-02-07 03:37:54 -08:00
parent de79440de2
commit 99fbc0fcb3
12 changed files with 169 additions and 28 deletions

View File

@@ -20,7 +20,9 @@ import (
"fmt"
"net"
"net/http"
"net/url"
"os"
"path/filepath"
"runtime"
"strconv"
"strings"
@@ -206,7 +208,10 @@ func (web *WebAPI) GetObjectURL(r *http.Request, args *GetObjectURLArgs, reply *
if e != nil {
return e
}
signedURLStr, e := client.PresignedGetObject(args.BucketName, args.ObjectName, time.Duration(60*60)*time.Second)
reqParams := make(url.Values)
// Set content disposition for browser to download the file.
reqParams.Set("response-content-disposition", fmt.Sprintf(`attachment; filename="%s"`, filepath.Base(args.ObjectName)))
signedURLStr, e := client.PresignedGetObject(args.BucketName, args.ObjectName, time.Duration(60*60)*time.Second, reqParams)
if e != nil {
return e
}