Upload a single file to FTP server with the provided FTP client object.

@param sourceFilePath
@param targetFilePath
@param logPrefix
@throws IOException
182289
protected void uploadFile(final FTPClient ftpClient, final String sourceFilePath, final String targetFilePath,
                              final String logPrefix) throws IOException {
        log.info(String.format(UPLOAD_FILE, logPrefix, sourceFilePath, targetFilePath));
        final File sourceFile = new File(sourceFilePath);
        try (final InputStream is = new FileInputStream(sourceFile)) {
            ftpClient.changeWorkingDirectory(targetFilePath);
            ftpClient.storeFile(sourceFile.getName(), is);

            final int replyCode = ftpClient.getReplyCode();
            final String replyMessage = ftpClient.getReplyString();
            if (isCommandFailed(replyCode)) {
                log.error(String.format(UPLOAD_FILE_REPLY, logPrefix, replyMessage));
                throw new IOException("Failed to upload file: " + sourceFilePath);
            } else {
                log.info(String.format(UPLOAD_FILE_REPLY, logPrefix, replyMessage));
            }
        }
    }
878455
protected function move(UploadFile $file, $targetPath)
    {
        $fileInfo = [
            'name' => pathinfo($targetPath, PATHINFO_BASENAME),
            'path' => $targetPath,
            'mime' => $file->getFileMime(),
            'size' => $file->getSize(),
        ];

        $file->moveTo($targetPath);

        if ( ! $file->getError()) {
            $this->uploadedFiles[] = $fileInfo;
        } else {
            $this->errors[] = $file->getError();
        }
    }
1119950
public <E extends Throwable> DbxEntry.File uploadFileChunked(String targetPath, DbxWriteMode writeMode, long numBytes, DbxStreamWriter<E> writer)
        throws DbxException, E
    {
        Uploader uploader = startUploadFileChunked(targetPath, writeMode, numBytes);
        return finishUploadFile(uploader, writer);
    }
1056963
protected function publishFile($sourceStream, $relativeTargetPathAndFilename, ResourceMetaDataInterface $metaData)
    {
        $objectName = $this->keyPrefix . $relativeTargetPathAndFilename;
        $options = array(
            'params' => array(
                'ContentLength' => $metaData->getFileSize(),
                'ContentType' => $metaData->getMediaType()
            )
        );

        try {
            $this->s3Client->upload($this->bucketName, $objectName, $sourceStream, 'public-read', $options);
            $this->systemLogger->log(sprintf('Successfully published resource as object "%s" in bucket "%s" with MD5 hash "%s"', $objectName, $this->bucketName, $metaData->getMd5() ?: 'unknown'), LOG_DEBUG);
        } catch (\Exception $e) {
            $this->systemLogger->log(sprintf('Failed publishing resource as object "%s" in bucket "%s" with MD5 hash "%s": %s', $objectName, $this->bucketName, $metaData->getMd5() ?: 'unknown', $e->getMessage()), LOG_DEBUG);
            if (is_resource($sourceStream)) {
                fclose($sourceStream);
            }
            throw $e;
        }
    }
35577
static void copyResources(URL resourceUrl, File targetPath) throws IOException, URISyntaxException {
        if (resourceUrl == null) {
            return;
        }

        URLConnection urlConnection = resourceUrl.openConnection();

        /**
         * Copy resources either from inside jar or from project folder.
         */
        if (urlConnection instanceof JarURLConnection) {
            copyJarResourceToPath((JarURLConnection) urlConnection, targetPath);
        } else if (VFS_PROTOCOL.equals(resourceUrl.getProtocol())) {
            VirtualFile virtualFileOrFolder = VFS.getChild(resourceUrl.toURI());
            copyFromWarToFolder(virtualFileOrFolder, targetPath);
        } else {
            File file = new File(resourceUrl.getPath());
            if (file.isDirectory()) {
                for (File resourceFile : FileUtils.listFiles(file, null, true)) {
                    int index = resourceFile.getPath().lastIndexOf(targetPath.getName()) + targetPath.getName().length();
                    File targetFile = new File(targetPath, resourceFile.getPath().substring(index));
                    if (!targetFile.exists() || targetFile.length() != resourceFile.length()) {
                        if (resourceFile.isFile()) {
                            FileUtils.copyFile(resourceFile, targetFile);
                        }
                    }
                }
            } else {
                if (!targetPath.exists() || targetPath.length() != file.length()) {
                    FileUtils.copyFile(file, targetPath);
                }
            }
        }
    }
572831
static void copyFileFromResources(String sourcePath, String destPath) throws IOException {
        LOGGER.entering(new Object[] { sourcePath, destPath });

        File downloadFile = new File(destPath);

        if (!downloadFile.exists()) {
            InputStream stream = JarSpawner.class.getResourceAsStream(sourcePath);
            FileUtils.copyInputStreamToFile(stream, downloadFile);
            LOGGER.fine("File copied to " + destPath);
        }
        LOGGER.exiting();
    }
389575
public synchronized void addFile(String filename, String filePath) {
        // fix this to check if duplicate name exists.
        int fileIndex = fileNameList.indexOf(filename);
        if (fileIndex == -1) {
            fileNameList.add(filename);
            filePathList.add(filePath);
        }
    }
1233988
protected void checkTarget(final File target) throws IOException {
        if (target == null) {
            throw new IOException("You must provide a target directory or file");
        }
        if (!target.exists()) {
            String extension = FilenameUtils.getExtension(target.getName());
            if (extension.length() == 0) {
                throw new IOException("Target folder " + target + " not found");
            }
        }
    }
342594
public static void copy(File sourceFile, File targetFile) throws IOException {
	FileInputStream in = new FileInputStream(sourceFile);
	try {
	    FileOutputStream out = new FileOutputStream(targetFile);
	    try {
		copy(in, out);
	    } finally {
		out.close();
	    }
	} finally {
	    in.close();
	}
    }
785714
public void addFile(String path, InputStream inputStream, String contentType) throws IOException {
    String fullPath = buildJcrPathForZip(path);
    writeBinaryFile(fullPath, inputStream);

    if (StringUtils.isNotEmpty(contentType)) {
      String mimeType = StringUtils.substringBefore(contentType, CONTENT_TYPE_CHARSET_EXTENSION);
      String encoding = StringUtils.substringAfter(contentType, CONTENT_TYPE_CHARSET_EXTENSION);

      String fullPathMetadata = fullPath + DOT_DIR_FOLDER + "/" + DOT_CONTENT_XML;
      Document doc = xmlContentBuilder.buildNtFile(mimeType, encoding);
      writeXmlDocument(fullPathMetadata, doc);
    }
  }
429004
function updatePathInternal(sourcePath, targetPath, options, log) {
    var rootDir = (options && options.rootDir) || "";
    var targetFullPath = path.join(rootDir, targetPath);
    var targetStats = fs.existsSync(targetFullPath) ? fs.statSync(targetFullPath) : null;
    var sourceStats = null;

    if (sourcePath) {
        // A non-null source path was specified. It should exist.
        var sourceFullPath = path.join(rootDir, sourcePath);
        if (!fs.existsSync(sourceFullPath)) {
            throw new Error("Source path does not exist: " + sourcePath);
        }

        sourceStats = fs.statSync(sourceFullPath);

        // Create the target's parent directory if it doesn't exist.
        var parentDir = path.dirname(targetFullPath);
        if (!fs.existsSync(parentDir)) {
            shell.mkdir("-p", parentDir);
        }
    }

    return updatePathWithStats(sourcePath, sourceStats, targetPath, targetStats, options, log);
}
639281
@Override
    public FileBuilder addDirectory(Path target) throws IOException
    {
        checkTarget(target);
        FileBuilder fb = new FileBuilder();
        fb.target = target;
        fb.content = ByteBuffer.allocate(0);
        fb.size = fb.content.limit();
        fb.mode = 040000;
        fb.compressFilename();
        fileBuilders.add(fb);
        return fb;
    }
438535
public static void openLogFile(String logPath) {
		if (logPath == null) {
			printStream = System.out;
		} else {
			try {
				printStream = new PrintStream(new File(logPath));
			} catch (FileNotFoundException e) {
				throw new IllegalArgumentException("Log file " + logPath + " was not found", e);
			}
		}
	}
1326964
private function createDirectoryIfNotExists($absoluteTargetPath)
    {
        if (File::isDirectory($absoluteTargetPath) && File::isWritable($absoluteTargetPath)) {
            return true;
        }

        try {
            @File::makeDirectory($absoluteTargetPath, 0777, true);

            return true;
        } catch (Exception $e) {
            throw new ImageuploadException($e->getMessage());
        }
    }
184549
protected boolean uploadDirectory(final String ftpServer, final String username, final String password,
                                      final String sourceDirectoryPath, final String targetDirectoryPath) {
        log.debug("FTP username: " + username);
        try {
            final FTPClient ftpClient = getFTPClient(ftpServer, username, password);

            log.info(String.format(UPLOAD_DIR_START, sourceDirectoryPath, targetDirectoryPath));
            uploadDirectory(ftpClient, sourceDirectoryPath, targetDirectoryPath, "");
            log.info(String.format(UPLOAD_DIR_FINISH, sourceDirectoryPath, targetDirectoryPath));

            ftpClient.disconnect();
            return true;
        } catch (Exception e) {
            log.debug(e);
            log.error(String.format(UPLOAD_DIR_FAILURE, sourceDirectoryPath, targetDirectoryPath));
        }

        return false;
    }
778160
public function validateFile(Entity\File $file, $sourceFilePath = null)
	{
		$size = $file->getSize();
		
		if ($size > $this->maxSize) {
			$message = 'File size is bigger than "' . $this->maxSize . '"';
			
			throw new Exception\UploadFilterException(self::EXCEPTION_MESSAGE_KEY, $message);
		}
	}
983301
private function dispatchPostUploadEvent($sourcefile, $targetfile)
    {
        if (null !== $this->_application &&
                null !== $this->_application->getEventDispatcher()) {
            $event = new \BackBee\Event\PostUploadEvent($sourcefile, $targetfile);
            $this->_application->getEventDispatcher()->dispatch('file.postupload', $event);
        }
    }