transfer a file from local to local
188654
def put_file(self, in_path, out_path):
        '''  '''

        vvv("PUT %s TO %s" % (in_path, out_path), host=self.host)
        if not os.path.exists(in_path):
            raise errors.AnsibleFileNotFound("file or module does not exist: %s" % in_path)
        try:
            shutil.copyfile(in_path, out_path)
        except shutil.Error:
            traceback.print_exc()
            raise errors.AnsibleError("failed to copy: %s and %s are the same" % (in_path, out_path))
        except IOError:
            traceback.print_exc()
            raise errors.AnsibleError("failed to transfer file to %s" % out_path)
534472
def fetch_file(self, in_path, out_path):
        '''  '''
        vvv("FETCH %s TO %s" % (in_path, out_path), host=self.host)
        try:
            self.sftp = self._connect_sftp()
        except:
            raise errors.AnsibleError("failed to open a SFTP connection")
        try:
            self.sftp.get(in_path, out_path)
        except IOError:
            raise errors.AnsibleError("failed to transfer file from %s" % in_path)
1167841
def send_file(self, local_path, remote_path, user='root', unix_mode=None):
        
        self.enable_user(user)
        return self.ssh_pool.send_file(user, local_path, remote_path, unix_mode=unix_mode)
1178041
private void copyToLocal(AlluxioURI srcPath, AlluxioURI dstPath) throws AlluxioException,
      IOException {
    URIStatus srcStatus = mFileSystem.getStatus(srcPath);
    File dstFile = new File(dstPath.getPath());
    if (srcStatus.isFolder()) {
      // make a local directory
      if (!dstFile.exists()) {
        if (!dstFile.mkdirs()) {
          throw new IOException("mkdir failure for directory: " + dstPath);
        } else {
          System.out.println("Create directory: " + dstPath);
        }
      }

      List<URIStatus> statuses;
      try {
        statuses = mFileSystem.listStatus(srcPath);
      } catch (AlluxioException e) {
        throw new IOException(e.getMessage());
      }

      List<String> errorMessages = new ArrayList<>();
      for (URIStatus status : statuses) {
        try {
          File subDstFile = new File(dstFile.getAbsolutePath(), status.getName());
          copyToLocal(
              new AlluxioURI(srcPath.getScheme(), srcPath.getAuthority(), status.getPath()),
              new AlluxioURI(dstPath.getScheme(), dstPath.getAuthority(), subDstFile.getPath()));
        } catch (IOException e) {
          errorMessages.add(e.getMessage());
        }
      }

      if (errorMessages.size() != 0) {
        throw new IOException(Joiner.on('\n').join(errorMessages));
      }
    } else {
      copyFileToLocal(srcPath, dstPath);
    }
  }
197328
public void get(String remoteFiles[], String localTargetDirectory) throws IOException {
        Session sess = null;

        if ((remoteFiles == null) || (localTargetDirectory == null))
            throw new IllegalArgumentException("Null argument.");

        if (remoteFiles.length == 0)
            return;

//        String cmd = "scp -f -r";
        String cmd = "scp -f ";

        for (int i = 0; i < remoteFiles.length; i++) {
            if (remoteFiles[i] == null)
                throw new IllegalArgumentException("Cannot accept null filename.");

            cmd += (" " + remoteFiles[i]);
        }

        try {
            sess = conn.openSession();
            sess.execCommand(cmd);
            receiveFiles(sess, remoteFiles, localTargetDirectory);
            sess.close();
        } catch (IOException e) {
            if (sess != null)
                sess.close();

            throw (IOException) new IOException("Error during SCP transfer.").initCause(e);
        }
    }
434582
function LocalFilesystemHandler(req, res, next, local = false) {
            if (!self.settings.localFilesystem) {
                return next();
            }
            return FilesystemHandler(req, res, next, self.localFilesystemUrl, undefined, local);
        }
943251
def _format_local_file(self):
        

        if self.type != 'file':
            return

        if not self.entity:
            return

        if not is_win:
            return

        if self._file_exists():
            return

        self.args.local_file = self._to_unc_path(self.entity)
709965
def _file_local_or_remote(f, get_retriever):
    
    if os.path.exists(f):
        return f
    integration, config = get_retriever.integration_and_config(f)
    if integration:
        return integration.file_exists(f, config)
632216
def sendLocalImage(
        self, image_path, message=None, thread_id=None, thread_type=ThreadType.USER
    ):
        
        return self.sendLocalFiles(
            file_paths=[image_path],
            message=message,
            thread_id=thread_id,
            thread_type=thread_type,
        )
862814
def upload!(local_file)
      @remote.directory.files.create(
        key:            local_file.key,
        body:           local_file.body,
        cache_control:  "public, max-age=#{max_age(local_file)}",
        public:         true
      )
    end
491200
def _set_local_file_path(self):
        

        self.FILE_LOCAL = self._transfer.get_env('FILE_LOCAL')

        if not self.FILE_LOCAL:
            filename = '{}_{}.{}'.format(str(self._transfer.prefix),
                                         str(self._transfer.namespace),
                                         str(self.file_extension))
            self.FILE_LOCAL = os.path.join(os.path.expanduser("~"), filename)

        dirs = os.path.dirname(self.FILE_LOCAL)
        if not os.path.exists(dirs):
            os.makedirs(dirs)

        try:
            open(self.FILE_LOCAL, "rb+").close()
        except:
            open(self.FILE_LOCAL, "a").close()
962399
public void get(String remoteFileName,
                    File localFile)
        throws IOException,
               ClientException,
               ServerException {
        if (gSession.transferMode == GridFTPSession.MODE_EBLOCK) {
            DataSink sink =
                new FileRandomIO(new RandomAccessFile(localFile, "rw"));
            get(remoteFileName, sink, null);
        } else {
            super.get(remoteFileName, localFile);
        }
    }
464401
def _transfer_str(self, conn, tmp, name, data):
        '''  '''

        if type(data) == dict:
            data = utils.jsonify(data)

        afd, afile = tempfile.mkstemp()
        afo = os.fdopen(afd, 'w')
        try:
            afo.write(data.encode('utf8'))
        except:
            raise errors.AnsibleError("failure encoding into utf-8")
        afo.flush()
        afo.close()

        remote = os.path.join(tmp, name)
        try:
            conn.put_file(afile, remote)
        finally:
            os.unlink(afile)
        return remote
605007
public SftpFile[] getFiles(String remote, String local)
			throws FileNotFoundException, SftpStatusException, SshException,
			TransferCancelledException {
		return getFiles(remote, local, false);
	}
55179
def put_file(self):
        """"""
        destination = "{}/{}".format(self.file_system, self.dest_file)
        self.scp_conn.scp_transfer_file(self.source_file, destination)
        # Must close the SCP connection to get the file written (flush)
        self.scp_conn.close()
28575
def copyfile(src, dest, no_progress_bar=False, name=None):
    """"""
    from dvc.progress import progress

    copied = 0
    name = name if name else os.path.basename(dest)
    total = os.stat(src).st_size

    if os.path.isdir(dest):
        dest = os.path.join(dest, os.path.basename(src))

    with open(src, "rb") as fsrc, open(dest, "wb+") as fdest:
        while True:
            buf = fsrc.read(LOCAL_CHUNK_SIZE)
            if not buf:
                break
            fdest.write(buf)
            copied += len(buf)
            if not no_progress_bar:
                progress.update_target(name, copied, total)

    if not no_progress_bar:
        progress.finish_target(name)
1040677
def up_by_files(to_sync, remote_dir=DEFAULT_REMOTE_DIR, remote_files=None):
    """"""
    if remote_files is None:
        remote_files = command.map_files_raw(remote_dir=remote_dir)
    for local_file in to_sync:
        _sync_local_file(local_file, remote_dir, remote_files)