Browse Source

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`
pull/84/head
Alexander Ustimenko 7 years ago
committed by GitHub
parent
commit
05df7fc453
1 changed files with 12 additions and 0 deletions
  1. +12
    -0
      server/handlers.go

+ 12
- 0
server/handlers.go 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
}



Loading…
Cancel
Save