Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E34F57511 for ; Mon, 7 Nov 2011 13:35:19 +0000 (UTC) Received: (qmail 52796 invoked by uid 500); 7 Nov 2011 13:35:19 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 52723 invoked by uid 500); 7 Nov 2011 13:35:19 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 52715 invoked by uid 99); 7 Nov 2011 13:35:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Nov 2011 13:35:19 +0000 X-ASF-Spam-Status: No, hits=-2001.2 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Nov 2011 13:35:12 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id A3A13387A4 for ; Mon, 7 Nov 2011 13:34:51 +0000 (UTC) Date: Mon, 7 Nov 2011 13:34:51 +0000 (UTC) From: "Allen Atamer (Updated) (JIRA)" To: issues@commons.apache.org Message-ID: <1438228759.6585.1320672891671.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <876359495.6580.1320672532129.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (NET-429) FTPClient storeFile method creates a file of 0 bytes MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/NET-429?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Allen Atamer updated NET-429: ----------------------------- Environment: jdk1.6.0_27 Windows 7 Pro SP1 local machine Uploading to a GoDaddy Linux shared hosting environment. File is created with 0x604 permissions. was: jdk1.6.0_27 Windows 7 Pro SP1 > FTPClient storeFile method creates a file of 0 bytes > ---------------------------------------------------- > > Key: NET-429 > URL: https://issues.apache.org/jira/browse/NET-429 > Project: Commons Net > Issue Type: Bug > Components: FTP > Affects Versions: 1.4, 3.0.1 > Environment: jdk1.6.0_27 > Windows 7 Pro SP1 local machine > Uploading to a GoDaddy Linux shared hosting environment. File is created with 0x604 permissions. > Reporter: Allen Atamer > Labels: bytes, ftp, storeFile, zero > > Using the FTPClient object in commons net the way it is shown in the Javadoc results in a file that is 0 bytes on the remote host. When you get to the storeFile(..) method, it waits for about 20 seconds before it returns the error message shown to System.out. > I've tried a number of different things > 1. commons-net version 3.0.1 (supposedly had the bug fix for this, but didn't work for me) > 2. [boolean] storeFile (String, InputStream) > 3. [OutputStream] storeFile (String) > 4. commons-net version 1.4 (still no dice) > Here's my code: > {quote} > boolean error = false; > FTPClient ftp = new FTPClient(); > InputStream localStream = null; > try { > int reply; > String server = "ftp.myserver.com"; > ftp.connect(server, 21); > System.out.println("Connected to " + server + "."); > System.out.print(ftp.getReplyString()); > // After connection attempt, you should check the reply code to > // verify > // success. > reply = ftp.getReplyCode(); > if (!FTPReply.isPositiveCompletion(reply)) { > ftp.disconnect(); > System.err.println("FTP server refused connection."); > System.exit(1); > } > boolean wasSuccessful = ftp.login("user", "password"); > if (!wasSuccessful) { > System.err.println("Login unsuccessful"); > System.exit(1); > } > > System.out.println("login successful"); > String localPath="C:/projects/TEMP/uga.html"; > File localFile = new File(localPath); > > if (localFile.exists()) { > localStream = new BufferedInputStream(new FileInputStream(localPath)); > wasSuccessful = ftp.storeFile("uga.html", localStream); > if (!wasSuccessful) { > System.err.println("could not store file: " + localPath); > System.exit(1); > } else { > System.out.println("Successfully saved file!"); > } > } > > // transfer files > ftp.logout(); > } catch (IOException e) { > error = true; > e.printStackTrace(); > } finally { > if (ftp.isConnected()) { > try { > ftp.disconnect(); > } catch (IOException ioe) { > // do nothing > } > } > if (localStream != null) { > try { > localStream.close(); > } catch (IOException e) { > } > } > System.exit(error ? 1 : 0); > } > {quote} > Here's my System.out: > {quote} > Connected to ftp.harmari.com. > 220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- > 220-You are user number 16 of 500 allowed. > 220-Local time is now 05:59. Server port: 21. > 220-This is a private system - No anonymous login > 220 You will be disconnected after 3 minutes of inactivity. > login successful > could not store file: 2482049866.html > {quote} > More background: > FileZilla works on my machine > I've also tried the primitive Sun API, and it works perfectly: > {quote} > try { > url = new URL("ftp://harmari:U!jXm95op@ftp.harmari.com/offline3/uga.html;type=i"); > URLConnection urlc = url.openConnection(); > OutputStream os = urlc.getOutputStream(); // To upload > > String localPath = "C:/projects/TEMP/uga.html"; > InputStream bis = new BufferedInputStream(new FileInputStream(localPath)); > > byte[] bstr = new byte[1024]; > while (bis.read(bstr) > 0) { > os.write(bstr); > } > } catch (MalformedURLException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } catch (IOException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > {quote} -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira