func (c *FilesInsertCall) Do() (*File, error) { var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.file) if err != nil { return nil, err } ctype := "application/json" params := make(url.Values) params.Set("alt", "json") if v, ok := c.opt_["fields"]; ok { params.Set("fields", fmt.Sprintf("%v", v)) } urls := googleapi.ResolveRelative(c.s.BasePath, "files") if c.media_ != nil { urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1) params.Set("uploadType", "multipart") } urls += "?" + params.Encode() contentLength_, hasMedia_ := googleapi.ConditionallyIncludeMedia(c.media_, &body, &ctype) req, _ := http.NewRequest("POST", urls, body) googleapi.SetOpaque(req.URL) 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) if err != nil { return nil, err } defer googleapi.CloseBody(res) if err := googleapi.CheckResponse(res); err != nil { return nil, err } var ret *File if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { return nil, err } return ret, nil // { // "description": "Inserts a file, and any settable metadata or blob content sent with the request.", // "httpMethod": "POST", // "id": "drive.files.insert", // "mediaUpload": { // "accept": [ // "*/*" // ], // "maxSize": "5120GB", // "protocols": { // "resumable": { // "multipart": true, // "path": "/resumable/upload/drive/v1/files" // }, // "simple": { // "multipart": true, // "path": "/upload/drive/v1/files" // } // } // }, // "path": "files", // "request": { // "$ref": "File" // }, // "response": { // "$ref": "File" // }, // "scopes": [ // "https://www.googleapis.com/auth/drive.file" // ], // "supportsMediaUpload": true // } }
func (c *FilesUpdateCall) Do() (*File, error) { var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.file) if err != nil { return nil, err } ctype := "application/json" params := make(url.Values) params.Set("alt", "json") if v, ok := c.opt_["newRevision"]; ok { params.Set("newRevision", fmt.Sprintf("%v", v)) } if v, ok := c.opt_["updateModifiedDate"]; ok { params.Set("updateModifiedDate", fmt.Sprintf("%v", v)) } if v, ok := c.opt_["updateViewedDate"]; ok { params.Set("updateViewedDate", fmt.Sprintf("%v", v)) } if v, ok := c.opt_["fields"]; ok { params.Set("fields", fmt.Sprintf("%v", v)) } urls := googleapi.ResolveRelative(c.s.BasePath, "files/{id}") if c.media_ != nil { urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1) params.Set("uploadType", "multipart") } urls += "?" + params.Encode() contentLength_, hasMedia_ := googleapi.ConditionallyIncludeMedia(c.media_, &body, &ctype) req, _ := http.NewRequest("PUT", urls, body) googleapi.Expand(req.URL, map[string]string{ "id": c.id, }) 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) if err != nil { return nil, err } defer googleapi.CloseBody(res) if err := googleapi.CheckResponse(res); err != nil { return nil, err } var ret *File if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { return nil, err } return ret, nil // { // "description": "Updates file metadata and/or content", // "httpMethod": "PUT", // "id": "drive.files.update", // "mediaUpload": { // "accept": [ // "*/*" // ], // "maxSize": "5120GB", // "protocols": { // "resumable": { // "multipart": true, // "path": "/resumable/upload/drive/v1/files/{id}" // }, // "simple": { // "multipart": true, // "path": "/upload/drive/v1/files/{id}" // } // } // }, // "parameterOrder": [ // "id" // ], // "parameters": { // "id": { // "description": "The id for the file in question.", // "location": "path", // "required": true, // "type": "string" // }, // "newRevision": { // "default": "true", // "description": "Whether a blob upload should create a new revision. If false, the blob data in the current head revision is replaced. If true or not set, a new blob is created as head revision, and previous revisions are preserved (causing increased use of the user's data storage quota).", // "location": "query", // "type": "boolean" // }, // "updateModifiedDate": { // "default": "false", // "description": "Controls updating the modified date of the file. If true, the modified date will be updated to the current time, regardless of whether other changes are being made. If false, the modified date will only be updated to the current time if other changes are also being made (changing the title, for example).", // "location": "query", // "type": "boolean" // }, // "updateViewedDate": { // "default": "true", // "description": "Whether to update the view date after successfully updating the file.", // "location": "query", // "type": "boolean" // } // }, // "path": "files/{id}", // "request": { // "$ref": "File" // }, // "response": { // "$ref": "File" // }, // "scopes": [ // "https://www.googleapis.com/auth/drive.file" // ], // "supportsMediaUpload": true // } }
func (c *FilesGetCall) Do() (*File, error) { var body io.Reader = nil params := make(url.Values) params.Set("alt", "json") if v, ok := c.opt_["projection"]; ok { params.Set("projection", fmt.Sprintf("%v", v)) } if v, ok := c.opt_["updateViewedDate"]; ok { params.Set("updateViewedDate", fmt.Sprintf("%v", v)) } if v, ok := c.opt_["fields"]; ok { params.Set("fields", fmt.Sprintf("%v", v)) } urls := googleapi.ResolveRelative(c.s.BasePath, "files/{id}") urls += "?" + params.Encode() req, _ := http.NewRequest("GET", urls, body) googleapi.Expand(req.URL, map[string]string{ "id": c.id, }) req.Header.Set("User-Agent", "google-api-go-client/0.5") res, err := c.s.client.Do(req) if err != nil { return nil, err } defer googleapi.CloseBody(res) if err := googleapi.CheckResponse(res); err != nil { return nil, err } var ret *File if err := json.NewDecoder(res.Body).Decode(&ret); err != nil { return nil, err } return ret, nil // { // "description": "Gets a file's metadata by id.", // "httpMethod": "GET", // "id": "drive.files.get", // "parameterOrder": [ // "id" // ], // "parameters": { // "id": { // "description": "The id for the file in question.", // "location": "path", // "required": true, // "type": "string" // }, // "projection": { // "description": "This parameter is deprecated and has no function.", // "enum": [ // "BASIC", // "FULL" // ], // "enumDescriptions": [ // "Deprecated", // "Deprecated" // ], // "location": "query", // "type": "string" // }, // "updateViewedDate": { // "default": "true", // "description": "Whether to update the view date after successfully retrieving the file.", // "location": "query", // "type": "boolean" // } // }, // "path": "files/{id}", // "response": { // "$ref": "File" // }, // "scopes": [ // "https://www.googleapis.com/auth/drive.file" // ] // } }