code: func (s *storageImpl) getNextOffset(ctx context.Context, url string, length int64) (offset int64, err error) {
  	r, err := http.NewRequest("PUT", url, nil)
  	if err != nil {
  		return
  	}
  	r.Header.Set("Content-Range", fmt.Sprintf("bytes */%d", length))
  	r.Header.Set("Content-Length", "0")
  	r.Header.Set("User-Agent", s.userAgent)
  	resp, err := ctxhttp.Do(ctx, s.client, r)
  	if err != nil {
  		if isTemporaryNetError(err) {
  			err = errTransientError
  		}
  		return
  	}
  	resp.Body.Close()
  
  	if resp.StatusCode == 200 {
  		// Fully uploaded.
  		offset = length
  	} else if resp.StatusCode == 308 {
  		// Partially uploaded, extract last uploaded offset from Range header.
  		rangeHeader := resp.Header.Get("Range")
  		if rangeHeader != "" {
  			_, err = fmt.Sscanf(rangeHeader, "bytes=0-%d", &offset)
  			if err == nil {
  				// |offset| is an *offset* of a last uploaded byte, not the data length.
  				offset++
  			}
  		}
  	} else if isTemporaryHTTPError(resp.StatusCode) {
  		err = errTransientError
  	} else {
  		err = fmt.Errorf("unexpected response (HTTP %d) when querying for uploaded offset", resp.StatusCode)
  	}
  	return
  }
docs: // getNextOffset queries the storage for size of persisted data.