code: func (r *Session) PushImageLayerRegistry(imgID string, layer io.Reader, registry string, jsonRaw []byte) (checksum string, checksumPayload string, err error) {
  	u := registry + "images/" + imgID + "/layer"
  
  	logrus.Debugf("[registry] Calling PUT %s", u)
  
  	tarsumLayer, err := tarsum.NewTarSum(layer, false, tarsum.Version0)
  	if err != nil {
  		return "", "", err
  	}
  	h := sha256.New()
  	h.Write(jsonRaw)
  	h.Write([]byte{'\n'})
  	checksumLayer := io.TeeReader(tarsumLayer, h)
  
  	req, err := http.NewRequest("PUT", u, checksumLayer)
  	if err != nil {
  		return "", "", err
  	}
  	req.Header.Add("Content-Type", "application/octet-stream")
  	req.ContentLength = -1
  	req.TransferEncoding = []string{"chunked"}
  	res, err := r.client.Do(req)
  	if err != nil {
  		return "", "", fmt.Errorf("Failed to upload layer: %v", err)
  	}
  	if rc, ok := layer.(io.Closer); ok {
  		if err := rc.Close(); err != nil {
  			return "", "", err
  		}
  	}
  	defer res.Body.Close()
  
  	if res.StatusCode != 200 {
  		errBody, err := ioutil.ReadAll(res.Body)
  		if err != nil {
  			return "", "", newJSONError(fmt.Sprintf("HTTP code %d while uploading metadata and error when trying to parse response body: %s", res.StatusCode, err), res)
  		}
  		return "", "", newJSONError(fmt.Sprintf("Received HTTP code %d while uploading layer: %q", res.StatusCode, errBody), res)
  	}
  
  	checksumPayload = "sha256:" + hex.EncodeToString(h.Sum(nil))
  	return tarsumLayer.Sum(jsonRaw), checksumPayload, nil
  }
docs: // PushImageLayerRegistry sends the checksum of an image layer to the registry