Logo Search packages:      
Sourcecode: jftp version File versions  Download package

int net::sf::jftp::net::FtpConnection::upload ( String  file,
String  realName,
InputStream  in 
) [inline]

Upload and a file or directory under a given name, block until finished. Note that setting realName does not affect directory transfers

Parameters:
file The file to upload
realName The file to rename the uploaded file to
in InputStream to read from
Returns:
An int responsecode

Definition at line 1576 of file FtpConnection.java.

References fireActionFinished(), fireDirectoryUpdate(), fireProgressUpdate(), and hasUploaded.

    {
        hasUploaded = true;
        Log.out("ftp upload started: " + this);

        int stat;

        if((in == null) && new File(file).isDirectory())
        {
            shortProgress = true;
            fileCount = 0;
            baseFile = file;
            dataType = DataConnection.PUTDIR;
            isDirUpload = true;

            stat = uploadDir(file);

            shortProgress = false;

            //System.out.println(fileCount + ":" + baseFile);
            fireProgressUpdate(baseFile,
                               DataConnection.DFINISHED + ":" + fileCount, -1);

            fireActionFinished(this);
            fireDirectoryUpdate(this);
        }
        else
        {
            dataType = DataConnection.PUT;
            stat = rawUpload(file, realName, in);

            try
            {
                Thread.sleep(100);
            }
            catch(Exception ex)
            {
            }

            fireActionFinished(this);
            fireDirectoryUpdate(this);
        }

        try
        {
            Thread.sleep(500);
        }
        catch(Exception ex)
        {
        }

        return stat;
    }


Generated by  Doxygen 1.6.0   Back to index