Add Max-Hours and Max-Seconds

Better will be to avoid copy-paste here and to use not headers for params, but url's params, like:
`curl --upload-file ./hello.txt https://transfer.sh/hello.txt?max-downloads=5`
This commit is contained in:
Alexander Ustimenko 2017-05-17 10:29:41 +07:00 committed by GitHub
parent 7bf499b092
commit 05df7fc453

View file

@ -319,6 +319,18 @@ func MetadataForRequest(contentType string, r *http.Request) Metadata {
metadata.MaxDate = time.Now().Add(time.Hour * 24 * time.Duration(v))
}
if v := r.Header.Get("Max-Hours"); v == "" {
} else if v, err := strconv.Atoi(v); err != nil {
} else {
metadata.MaxDate = time.Now().Add(time.Hour * time.Duration(v))
}
if v := r.Header.Get("Max-Seconds"); v == "" {
} else if v, err := strconv.Atoi(v); err != nil {
} else {
metadata.MaxDate = time.Now().Add(time.Second * time.Duration(v))
}
return metadata
}