What's the problem
I have a url with an image in it, and I want to send the image in a post request. Is there a way to do it without downloading the file locally?
What have I tried
Usually I would download the image, send the image, and delete the file. Is there a better way?
response, e := http.Get(url)
if e != nil {
log.Fatal(e)
}
writer := multipart.NewWriter(body)
part, err := writer.CreateFormFile(paramName, filepath.Base(path))
if err != nil {
return nil, err
}
_, err = io.Copy(part, file)