google-api-go-client: fix uploads broken by missing body

This was caused by:
https://code-review.googlesource.com/#/c/1500

Change-Id: I475679cb33bee053601e34719ce00712045fa441
Reviewed-on: https://code-review.googlesource.com/1860
Reviewed-by: Glenn Lewis <gmlewis@google.com>
diff --git a/google-api-go-generator/gen.go b/google-api-go-generator/gen.go
index a720f00..81f9005 100644
--- a/google-api-go-generator/gen.go
+++ b/google-api-go-generator/gen.go
@@ -1328,6 +1328,11 @@
 			pn(`ctype := "application/json"`)
 			hasContentType = true
 		}
+		pn("var contentLength_ int64")
+		pn("var hasMedia_ bool")
+		pn(`if c.protocol_ != "resumable" {`)
+		pn(" contentLength_, hasMedia_ = googleapi.ConditionallyIncludeMedia(c.media_, &body, &ctype)")
+		pn("}")
 	}
 	pn("req, _ := http.NewRequest(%q, urls, body)", httpMethod)
 	// Replace param values after NewRequest to avoid reencoding them.
@@ -1355,12 +1360,9 @@
 		pn(` if params.Get("name") == "" {`)
 		pn(`  return %sfmt.Errorf("resumable uploads must set the Name parameter.")`, nilRet)
 		pn(" }")
-		pn("} else {")
-		pn(" contentLength_, hasMedia_ := googleapi.ConditionallyIncludeMedia(c.media_, &body, &ctype)")
-		pn(" if hasMedia_ {")
-		pn("  req.ContentLength = contentLength_")
-		pn(`  req.Header.Set("Content-Type", ctype)`)
-		pn(" }")
+		pn("} else if hasMedia_ {")
+		pn(" req.ContentLength = contentLength_")
+		pn(` req.Header.Set("Content-Type", ctype)`)
 		pn("}")
 	} else if hasContentType {
 		pn(`req.Header.Set("Content-Type", ctype)`)
diff --git a/storage/v1/storage-gen.go b/storage/v1/storage-gen.go
index 4dc8693..06289fb 100644
--- a/storage/v1/storage-gen.go
+++ b/storage/v1/storage-gen.go
@@ -4508,6 +4508,11 @@
 		params.Set("uploadType", c.protocol_)
 	}
 	urls += "?" + params.Encode()
+	var contentLength_ int64
+	var hasMedia_ bool
+	if c.protocol_ != "resumable" {
+		contentLength_, hasMedia_ = googleapi.ConditionallyIncludeMedia(c.media_, &body, &ctype)
+	}
 	req, _ := http.NewRequest("POST", urls, body)
 	googleapi.Expand(req.URL, map[string]string{
 		"bucket": c.bucket,
@@ -4522,12 +4527,9 @@
 		if params.Get("name") == "" {
 			return nil, fmt.Errorf("resumable uploads must set the Name parameter.")
 		}
-	} else {
-		contentLength_, hasMedia_ := googleapi.ConditionallyIncludeMedia(c.media_, &body, &ctype)
-		if hasMedia_ {
-			req.ContentLength = contentLength_
-			req.Header.Set("Content-Type", ctype)
-		}
+	} else if hasMedia_ {
+		req.ContentLength = contentLength_
+		req.Header.Set("Content-Type", ctype)
 	}
 	req.Header.Set("User-Agent", "google-api-go-client/0.5")
 	res, err := c.s.client.Do(req)