Skip to content

Instantly share code, notes, and snippets.

@artemnikitin
Created September 29, 2017 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artemnikitin/d8caa2862c0b7762064f5fec39804f91 to your computer and use it in GitHub Desktop.
Save artemnikitin/d8caa2862c0b7762064f5fec39804f91 to your computer and use it in GitHub Desktop.
func sendRequest(url string, file *io.Reader, info os.FileInfo) *http.Response {
client := &http.Client{
Timeout: 10 * time.Minute,
}
request, err := http.NewRequest("PUT", url, *file)
errors.Validate(err, "Failed to create HTTP request")
request.Header.Add("Content-Type", "application/octet-stream")
request.ContentLength = info.Size()
resp, err := client.Do(request)
errors.Validate(err, "Failed to upload file by S3 link")
return resp
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment