func (s *router) postContainersCopy(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
	if vars == nil {
		return fmt.Errorf("Missing parameter")
	}

	if err := httputils.CheckForJSON(r); err != nil {
		return err
	}

	cfg := types.CopyConfig{}
	if err := json.NewDecoder(r.Body).Decode(&cfg); err != nil {
		return err
	}

	if cfg.Resource == "" {
		return fmt.Errorf("Path cannot be empty")
	}

	data, err := s.daemon.ContainerCopy(vars["name"], cfg.Resource)
	if err != nil {
		if strings.Contains(strings.ToLower(err.Error()), "no such id") {
			w.WriteHeader(http.StatusNotFound)
			return nil
		}
		if os.IsNotExist(err) {
			return fmt.Errorf("Could not find the file %s in container %s", cfg.Resource, vars["name"])
		}
		return err
	}
	defer data.Close()

	w.Header().Set("Content-Type", "application/x-tar")
	if _, err := io.Copy(w, data); err != nil {
		return err
	}

	return nil
}
// postContainersCopy is deprecated in favor of getContainersArchive.
postContainersCopy is deprecated in favor of getContainersArchive.
// postContainersCopy is deprecated in favor of getContainersArchive .
func (s *router) postContainersCopy(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
	if vars == nil {
		return fmt.Errorf("Missing parameter")
	}
	if err := httputils.CheckForJSON(r); err != nil {
		return err
	}
	cfg := types.CopyConfig{}
	if err := json.NewDecoder(r.Body).Decode(&cfg); err != nil {
		return err
	}
	if cfg.Resource == "" {
		return fmt.Errorf("Path cannot be empty")
	}
	data, err := s.daemon.ContainerCopy(vars["name"], cfg.Resource)
	if err != nil {
		if strings.Contains(strings.ToLower(err.Error()), "no such id") {
			w.WriteHeader(http.StatusNotFound)
			return nil
		}
		if os.IsNotExist(err) {
			return fmt.Errorf("Could not find the file %s in container %s", cfg.Resource, vars["name"])
		}
		return err
	}
	defer data.Close()
	w.Header().Set("Content-Type", "application/x-tar")
	if _, err := io.Copy(w, data); err != nil {
		return err
	}
	return nil
}
func ( s * router ) postContainersCopy ( ctx context . Context , w http . ResponseWriter , r * http . Request , vars map [ string ] string ) error { if vars == nil { return fmt . Errorf ( " " ) } if err := httputils . CheckForJSON ( r ) ; err != nil { return err } cfg := types . CopyConfig { } if err := json . NewDecoder ( r . Body ) . Decode ( & cfg ) ; err != nil { return err } if cfg . Resource == " " { return fmt . Errorf ( " " ) } data , err := s . daemon . ContainerCopy ( vars [ " " ] , cfg . Resource ) if err != nil { if strings . Contains ( strings . ToLower ( err . Error ( ) ) , " " ) { w . WriteHeader ( http . StatusNotFound ) return nil } if os . IsNotExist ( err ) { return fmt . Errorf ( " " , cfg . Resource , vars [ " " ] ) } return err } defer data . Close ( ) w . Header ( ) . Set ( " " , " " ) if _ , err := io . Copy ( w , data ) ; err != nil { return err } return nil }
postContainersCopy is deprecated in favor of getContainersArchive.
postContainersCopy is deprecated in favor of getContainersArchive .