Ejemplo n.º 1
0
func (c *Client) ReceiveBlob(blob *blobref.BlobRef, source io.Reader) (blobref.SizedBlobRef, error) {
	size, ok := readerutil.ReaderSize(source)
	if !ok {
		size = -1
	}
	h := &UploadHandle{
		BlobRef:  blob,
		Size:     size, // -1 if we don't know
		Contents: source,
	}
	pr, err := c.Upload(h)
	if err != nil {
		return blobref.SizedBlobRef{}, err
	}
	return pr.SizedBlobRef(), nil
}
Ejemplo n.º 2
0
func (c *Client) ReceiveBlob(br blob.Ref, source io.Reader) (blob.SizedRef, error) {
	if c.sto != nil {
		return blobserver.Receive(c.sto, br, source)
	}
	size, ok := readerutil.ReaderSize(source)
	if !ok {
		size = 0
	}
	h := &UploadHandle{
		BlobRef:  br,
		Size:     uint32(size), // 0 if we don't know
		Contents: source,
		SkipStat: true,
	}
	pr, err := c.Upload(h)
	if err != nil {
		return blob.SizedRef{}, err
	}
	return pr.SizedBlobRef(), nil
}