gensupport

package
v0.0.0-...-5d1b9c1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2019 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package gensupport is an internal implementation detail used by code generated by the google-api-go-generator tool.

This package may be modified at any time without regard for backwards compatibility. It should not be used directly by API users.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CombineBodyMedia

func CombineBodyMedia(body io.Reader, bodyContentType string, media io.Reader, mediaContentType string) (io.ReadCloser, string)

CombineBodyMedia combines a json body with media content to create a multipart/related HTTP body. It returns a ReadCloser containing the combined body, and the overall "multipart/related" content type, with random boundary.

The caller must call Close on the returned ReadCloser if reads are abandoned before reaching EOF.

func DetectMediaType

func DetectMediaType(media io.ReaderAt) string

DetectMediaType detects and returns the content type of the provided media. If the type can not be determined, "application/octet-stream" is returned.

func DetermineContentType

func DetermineContentType(media io.Reader, ctype string) (io.Reader, string)

DetermineContentType determines the content type of the supplied reader. If the content type is already known, it can be specified via ctype. Otherwise, the content of media will be sniffed to determine the content type. If media implements googleapi.ContentTyper (deprecated), this will be used instead of sniffing the content. After calling DetectContentType the caller must not perform further reads on media, but rather read from the Reader that is returned.

func MarshalJSON

func MarshalJSON(schema interface{}, forceSendFields []string) ([]byte, error)

MarshalJSON returns a JSON encoding of schema containing only selected fields. A field is selected if:

  • it has a non-empty value, or
  • its field name is present in forceSendFields, and
  • it is not a nil pointer or nil interface.

The JSON key for each selected field is taken from the field's json: struct tag.

Types

type ResumableBuffer

type ResumableBuffer struct {
	// contains filtered or unexported fields
}

ResumableBuffer buffers data from an io.Reader to support uploading media in retryable chunks.

func NewResumableBuffer

func NewResumableBuffer(media io.Reader, chunkSize int) *ResumableBuffer

func (*ResumableBuffer) Chunk

func (rb *ResumableBuffer) Chunk() (chunk io.Reader, off int64, size int, err error)

Chunk returns the current buffered chunk, the offset in the underlying media from which the chunk is drawn, and the size of the chunk. Successive calls to Chunk return the same chunk between calls to Next.

func (*ResumableBuffer) Next

func (rb *ResumableBuffer) Next()

Next advances to the next chunk, which will be returned by the next call to Chunk. Calls to Next without a corresponding prior call to Chunk will have no effect.

type ResumableUpload

type ResumableUpload struct {
	Client *http.Client
	// URI is the resumable resource destination provided by the server after specifying "&uploadType=resumable".
	URI       string
	UserAgent string // User-Agent for header of the request
	// Media is the object being uploaded.
	Media io.ReaderAt
	// MediaType defines the media type, e.g. "image/jpeg".
	MediaType string
	// ContentLength is the full size of the object being uploaded.
	ContentLength int64

	// Callback is an optional function that will be periodically called with the cumulative number of bytes uploaded.
	Callback func(int64)
	// contains filtered or unexported fields
}

ResumableUpload is used by the generated APIs to provide resumable uploads. It is not used by developers directly.

func (*ResumableUpload) Progress

func (rx *ResumableUpload) Progress() int64

Progress returns the number of bytes uploaded at this point.

func (*ResumableUpload) Upload

func (rx *ResumableUpload) Upload(ctx context.Context) (*http.Response, error)

Upload starts the process of a resumable upload with a cancellable context. It retries indefinitely (with a pause of uploadPause between attempts) until cancelled. It is called from the auto-generated API code and is not visible to the user. rx is private to the auto-generated API code.

type URLParams

type URLParams map[string][]string

URLParams is a simplified replacement for url.Values that safely builds up URL parameters for encoding.

func (URLParams) Encode

func (u URLParams) Encode() string

Encode encodes the values into “URL encoded” form ("bar=baz&foo=quux") sorted by key.

func (URLParams) Set

func (u URLParams) Set(key, value string)

Set sets the key to value. It replaces any existing values.

func (URLParams) SetMulti

func (u URLParams) SetMulti(key string, values []string)

SetMulti sets the key to an array of values. It replaces any existing values. Note that values must not be modified after calling SetMulti so the caller is responsible for making a copy if necessary.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL