abujehad139 / google-api-go-client

Automatically exported from code.google.com/p/google-api-go-client
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

bigquery JobsInsertCall.Do() should always use application/octet-stream for media #31

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create bigquery.Service
2. Add Job to load data to BigQuery with CSV data provided as POST
3. add Media
4. call Do

What is the expected output? What do you see instead?
Media (CSV data) should be added with "Content-Type: application/octet-stream"

If it is compressed it gets added with application/gzip and if the CSV data is 
not compressed (as created by http://golang.org/pkg/encoding/csv/) it is 
identified as text/plain.

What version of the product are you using? On what operating system?
Go working from tip
google-api-go-client working from tip
Linux x86_64

Please provide any additional information below.
According to the documentation provided for BigQuery the data section of the 
load job should always have the content type application/octet-stream.  You can 
work around this by creating a custom io.Reader that satisfies the type 
googleapi.ContentTyper interface, but that is not obvious and there is no case 
where this function should use anything other than content type 
application/octet-stream.

func (c *JobsInsertCall) Do() (*Job, error) {
         ...
        contentLength_, hasMedia_ := googleapi.ConditionallyIncludeMedia(c.media_, &body, &ctype)
         ...
}

This is just another pitfall for anyone brave/dumb enough to try to use Go with 
BigQuery - myself included.

Original issue reported on code.google.com by gaval...@gmail.com on 2 May 2013 at 2:36