// Put copies one or more local files to the remote host, using scp. localfiles can
// contain wildcards, and remotefile can be either a directory or a file.
558848
func (config *Config) Put(localfiles string, remotefile string) error {

	files, err := filepath.Glob(localfiles)
	if err != nil {
		if config.AbortOnError == true {
			log.Fatalf("%s", err)
		}
		return err
	}
	if len(files) == 0 {
		err = fmt.Errorf("No files match %s", localfiles)
		if config.AbortOnError == true {
			log.Fatalf("%s", err)
		}
		return err
	}
	for _, localfile := range files {

		fmt.Printf("put: %s %s\n", localfile, remotefile)
		contents, err := ioutil.ReadFile(localfile)
		if err != nil {
			if config.AbortOnError == true {
				log.Fatalf("%s", err)
			}
			return err
		}

		// get the local file mode bits
		fi, err := os.Stat(localfile)
		if err != nil {
			if config.AbortOnError == true {
				log.Fatalf("%s", err)
			}
			return err
		}
		// the file mode bits are the 9 least significant bits of Mode()
		mode := fi.Mode() & 1023

		session, err := config.connect()
		if err != nil {
			if config.AbortOnError == true {
				log.Fatalf("%s", err)
			}
			return err
		}
		var stdoutBuf bytes.Buffer
		var stderrBuf bytes.Buffer
		session.Stdout = &stdoutBuf
		session.Stderr = &stderrBuf

		w, _ := session.StdinPipe()

		_, lfile := filepath.Split(localfile)
		err = session.Start("/usr/bin/scp -qrt " + remotefile)
		if err != nil {
			w.Close()
			session.Close()
			if config.AbortOnError == true {
				log.Fatalf("%s", err)
			}
			return err
		}
		fmt.Fprintf(w, "C%04o %d %s\n", mode, len(contents), lfile /*remotefile*/)
		w.Write(contents)
		fmt.Fprint(w, "\x00")
		w.Close()

		err = session.Wait()
		if err != nil {
			if config.AbortOnError == true {
				log.Fatalf("%s", err)
			}
			session.Close()
			return err
		}

		if config.DisplayOutput == true {
			stdout := stdoutBuf.String()
			stderr := stderrBuf.String()
			fmt.Printf("%s%s", stderr, stdout)
		}
		session.Close()

	}

	return nil
}
843111
func (c *container) Put(name string, r io.Reader, size int64, metadata map[string]interface{}) (stow.Item, error) {
	mdPrepped, err := prepMetadata(metadata)
	if err != nil {
		return nil, errors.Wrap(err, "unable to create or update Item, preparing metadata")
	}

	_, err = c.client.ObjectPut(c.id, name, r, false, "", "", nil)
	if err != nil {
		return nil, errors.Wrap(err, "unable to create or update Item")
	}

	err = c.client.ObjectUpdate(c.id, name, mdPrepped)
	if err != nil {
		return nil, errors.Wrap(err, "unable to update Item metadata")
	}

	item := &item{
		id:        name,
		container: c,
		client:    c.client,
		size:      size,
		// not setting metadata here, the refined version isn't available
		// unless an explicit getItem() is done. Possible to write a func to facilitate
		// this.
	}
	return item, nil
}
772235
func (w *EtcdSafePointKV) Put(k string, v string) error {
	ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
	_, err := w.cli.Put(ctx, k, v)
	cancel()
	if err != nil {
		return errors.Trace(err)
	}
	return nil
}
1193546
func (session *Session) Put(path string, params Params) (Result, error) {
	return session.Api(path, PUT, params)
}
261790
func (b *BlockServerDisk) Put(
	ctx context.Context, tlfID tlf.ID, id kbfsblock.ID,
	context kbfsblock.Context, buf []byte,
	serverHalf kbfscrypto.BlockCryptKeyServerHalf,
	_ DiskBlockCacheType) (err error) {
	if err := checkContext(ctx); err != nil {
		return err
	}

	defer func() {
		err = translateToBlockServerError(err)
	}()
	b.log.CDebugf(ctx, "BlockServerDisk.Put id=%s tlfID=%s context=%s size=%d",
		id, tlfID, context, len(buf))

	if context.GetRefNonce() != kbfsblock.ZeroRefNonce {
		return errors.New("can't Put() a block with a non-zero refnonce")
	}

	tlfStorage, err := b.getStorage(tlfID)
	if err != nil {
		return err
	}

	tlfStorage.lock.Lock()
	defer tlfStorage.lock.Unlock()
	if tlfStorage.store == nil {
		return errBlockServerDiskShutdown
	}

	_, err = tlfStorage.store.put(ctx, true, id, context, buf, serverHalf)
	if err != nil {
		return err
	}
	err = tlfStorage.store.addReference(ctx, id, context, "tag")
	if err != nil {
		return err
	}
	return nil
}
633727
func (s *Server) Put(path string, h HandlerFunc, opts ...HandlerOption) {
	s.register(http.MethodPut, path, h, opts...)
}
994993
func (svc *DynamoAccessor) Put(ctx context.Context, keyPath string, object interface{}) error {

	// What's the type of the object?
	if object == nil {
		return errors.New("DynamoAccessor Put object must not be nil")
	}
	// Map it...
	marshal, marshalErr := dynamodbattribute.MarshalMap(object)
	if marshalErr != nil {
		return marshalErr
	}
	// TODO - consider using tags for this...
	_, idExists := marshal[attrID]
	if !idExists {
		marshal[attrID] = &dynamodb.AttributeValue{
			S: aws.String(keyPath),
		}
	}
	putItemInput := &dynamodb.PutItemInput{
		TableName: aws.String(svc.dynamoTableName()),
		Item:      marshal,
	}
	_, putItemErr := svc.dynamoSvc(ctx).PutItemWithContext(ctx, putItemInput)
	return putItemErr
}
631329
func (s *GlobalStore) Put(addr common.Address, key []byte, data []byte) error {
	s.mu.Lock()
	defer s.mu.Unlock()

	if i, found := s.nodeKeyIndex(addr, key); !found {
		s.nodeKeys[addr] = append(s.nodeKeys[addr], nil)
		copy(s.nodeKeys[addr][i+1:], s.nodeKeys[addr][i:])
		s.nodeKeys[addr][i] = key
	}

	if i, found := s.keyNodeIndex(key, addr); !found {
		k := string(key)
		s.keyNodes[k] = append(s.keyNodes[k], addr)
		copy(s.keyNodes[k][i+1:], s.keyNodes[k][i:])
		s.keyNodes[k][i] = addr
	}

	if i, found := s.nodeIndex(addr); !found {
		s.nodes = append(s.nodes, addr)
		copy(s.nodes[i+1:], s.nodes[i:])
		s.nodes[i] = addr
	}

	if i, found := s.keyIndex(key); !found {
		s.keys = append(s.keys, nil)
		copy(s.keys[i+1:], s.keys[i:])
		s.keys[i] = key
	}

	s.data[string(key)] = data

	return nil
}
1116616
func Put(path string, h interface{}, m ...interface{}) {
	Default.Put(path, h, m...)
}
1155196
func (svc *S3Accessor) Put(ctx context.Context, keyPath string, object interface{}) error {
	jsonBytes, jsonBytesErr := json.Marshal(object)
	if jsonBytesErr != nil {
		return jsonBytesErr
	}

	logger, _ := ctx.Value(sparta.ContextKeyLogger).(*logrus.Logger)
	logger.WithFields(logrus.Fields{
		"Bytes":   string(jsonBytes),
		"KeyPath": keyPath}).Debug("Saving S3 object")

	bytesReader := bytes.NewReader(jsonBytes)
	putObjectInput := &s3.PutObjectInput{
		Bucket: aws.String(svc.s3BucketName()),
		Key:    aws.String(keyPath),
		Body:   bytesReader,
	}
	putObjectResponse, putObjectRespErr := svc.
		s3Svc(ctx).
		PutObjectWithContext(ctx, putObjectInput)

	logger.WithFields(logrus.Fields{
		"Error":   putObjectRespErr,
		"Results": putObjectResponse}).Debug("Save object results")

	return putObjectRespErr
}
1279834
func (c ChannelAwareFakeClient) Put(path string, value interface{}) error {
	return c.charmstore.Put(path, value)
}
1351211
func (b *batch) Put(key, value []byte) error {
	b.b.Put(key, value)
	b.size += len(value)
	return nil
}
90883
func (f *fsClient) put(reader io.Reader, size int64, metadata map[string][]string, progress io.Reader) (int64, *probe.Error) {
	// ContentType is not handled on purpose.
	// For filesystem this is a redundant information.

	// Extract dir name.
	objectDir, objectName := filepath.Split(f.PathURL.Path)

	if objectDir != "" {
		// Create any missing top level directories.
		if e := os.MkdirAll(objectDir, 0777); e != nil {
			err := f.toClientError(e, f.PathURL.Path)
			return 0, err.Trace(f.PathURL.Path)
		}

		// Check if object name is empty, it must be an empty directory
		if objectName == "" {
			return 0, nil
		}
	}

	objectPath := f.PathURL.Path
	avoidResumeUpload := isStreamFile(objectPath)
	// Write to a temporary file "object.part.minio" before commit.
	objectPartPath := objectPath + partSuffix
	if avoidResumeUpload {
		objectPartPath = objectPath
	}

	// If exists, open in append mode. If not create it the part file.
	partFile, e := os.OpenFile(objectPartPath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666)
	if e != nil {
		err := f.toClientError(e, f.PathURL.Path)
		return 0, err.Trace(f.PathURL.Path)
	}

	// Get stat to get the current size.
	partSt, e := os.Stat(objectPartPath)
	if e != nil {
		err := f.toClientError(e, objectPartPath)
		return 0, err.Trace(objectPartPath)
	}

	var totalWritten int64
	// Current file offset.
	var currentOffset = partSt.Size()

	if !isStdIO(reader) && size > 0 {
		reader = hookreader.NewHook(reader, progress)
		if seeker, ok := reader.(io.Seeker); ok {
			if _, e = seeker.Seek(currentOffset, 0); e != nil {
				return 0, probe.NewError(e)
			}
			// Discard bytes until currentOffset.
			if _, e = io.CopyN(ioutil.Discard, progress, currentOffset); e != nil {
				return 0, probe.NewError(e)
			}
		}
	} else {
		reader = hookreader.NewHook(reader, progress)
		// Discard bytes until currentOffset.
		if _, e = io.CopyN(ioutil.Discard, reader, currentOffset); e != nil {
			return 0, probe.NewError(e)
		}
	}

	n, e := io.Copy(partFile, reader)
	if e != nil {
		return 0, probe.NewError(e)
	}

	// Save currently copied total into totalWritten.
	totalWritten = n + currentOffset

	// Close the input reader as well, if possible.
	closer, ok := reader.(io.Closer)
	if ok {
		if e = closer.Close(); e != nil {
			return totalWritten, probe.NewError(e)
		}
	}

	// Close the file before rename.
	if e = partFile.Close(); e != nil {
		return totalWritten, probe.NewError(e)
	}

	// Following verification is needed only for input size greater than '0'.
	if size > 0 {
		// Unexpected EOF reached (less data was written than expected).
		if totalWritten < size {
			return totalWritten, probe.NewError(UnexpectedEOF{
				TotalSize:    size,
				TotalWritten: totalWritten,
			})
		}
		// Unexpected ExcessRead (more data was written than expected).
		if totalWritten > size {
			return totalWritten, probe.NewError(UnexpectedExcessRead{
				TotalSize:    size,
				TotalWritten: totalWritten,
			})
		}
	}
	if !avoidResumeUpload {
		// Safely completed put. Now commit by renaming to actual filename.
		if e = os.Rename(objectPartPath, objectPath); e != nil {
			err := f.toClientError(e, objectPath)
			return totalWritten, err.Trace(objectPartPath, objectPath)
		}
	}
	return totalWritten, nil
}
251100
func (m *MockRestClientInterface) Put() *rest.Request {
	ret := m.ctrl.Call(m, "Put")
	ret0, _ := ret[0].(*rest.Request)
	return ret0
}
68225
func (s *storeImpl) Put(ctx datastore.Context, svc *Service) error {
	//No need to store ConfigFiles
	defer ctx.Metrics().Stop(ctx.Metrics().Start("ServiceStore.Put"))
	svc.ConfigFiles = make(map[string]servicedefinition.ConfigFile)

	err := s.ds.Put(ctx, Key(svc.ID), svc)
	if err == nil {
		s.updateVolatileInfo(svc.ID, svc.DesiredState, svc.UpdatedAt) // Uses Mutex Lock
	}
	return err
}
424077
func (m *MultiMap) Put(key interface{}, value interface{}) {
	m.m[key] = append(m.m[key], value)
}
1332699
func (rc *RequestConfig) PUT(path string) *RequestConfig {
	rc.Path = path
	rc.Method = "PUT"

	return rc
}