This project is read-only.
1
Vote

msi file upload - Binary Mode

description

Hi,
Many thanks for the runner it has been very useful.
However I am having an issue when trying to upload an msi file to an ftp server.
The resulting file on the server is smaller than the original file.
Is there any way to make the ftp session use binary uploading as it seems it may be using ascii at present?
 
Thanks,
 
Conor

comments

optonaegele wrote Oct 17, 2012 at 3:58 PM

Hi,
we had the same problem and solved it by modifing the DoUpload-Method (FTPBuildProcess.java) in the following way:
private void DoUpload(String relativePath, FTPClient client, File currDirectory) throws Exception
{
    String[] entries = currDirectory.list();
    byte[] buffer = new byte[4096]; // Create a buffer for copying
    int bytesRead;

    if(!StringUtil.isEmpty(relativePath))
    {
        String folderName = currDirectory.getName();
        logger.progressMessage("Changing Remote Path To: " + folderName);

        if(!client.changeWorkingDirectory(folderName))
        {
            logger.progressMessage("Creating Remote Path: " + folderName);
            client.makeDirectory(folderName);
            if(!client.changeWorkingDirectory(folderName))
            {
                throw new Exception("Unable to create remote structure!");
            }
        }
    }

    logger.progressMessage("Working On: " + currDirectory.getAbsolutePath());
    for (int i = 0; i < entries.length; i++)
    {
        File f = new File(currDirectory, entries[i]);
        if (f.isDirectory())
        {
            DoUpload(relativePath + f.getName() + "/", client, f);
            client.changeWorkingDirectory("..");
        }
        else
        {
            String path = "";
            if(relativePath.trim().length() == 0)
                path = f.getName();
            else
                path = relativePath + f.getName();

            FileInputStream in = new FileInputStream(f); // Stream to read file
            logger.progressMessage("Uploading File: " + path);
            client.setFileType(FTP.BINARY_FILE_TYPE); //This line has been added to fix the issue
            client.storeFile(f.getName(), in);
            in.close();
        }
    }
}

wrote Feb 13, 2013 at 11:05 PM