leere Datei auf FTP Server

  • 2 Antworten
  • Letztes Antwortdatum
B

Braesident

Ambitioniertes Mitglied
1
Hi Leute,

kann mir jemand sagen warum meine Datei die ich hochlade immer leer bzw. beschädigt ist.
storeFile scheint keine Exception zu liefern, die Rückgabe ist aber immer false.
Der Aufruf findet in einem AsyncTask statt.
Als Server fungiert meine FritzBox mit nem USB Stick. eingestellt ist Nur sichere Verbindungen (FTPS).

EDIT: hab mir jetzt nochmal die Meldungen genauer angesehen. Wobei auch 2 Errors dabei sind.
Code:
D/MainActivity: toServerViaFtp - start

W/Trace:    Unexpected value from nativeGetEnabledTags: 0
D/libc-netbsd:    getaddrinfo: name.host.eu get result from proxy >>
I/System.out:    propertyValue:true
I/System.out:    [socket][2] connection name.host.eu/meineIP:21;LocalPort=51668(0)
I/System.out:    [CDS]connect[name.host.eu/meineIP:21] tm:90
D/Posix:    [Posix_connect Debug]Process de.meine.app :21
I/System.out:    [socket][/192.168.178.31:51668] connected
I/System.out:    [CDS]rx timeout:0
W/Trace:    Unexpected value from nativeGetEnabledTags: 0
D/dalvikvm:    GC_CONCURRENT freed 379K, 5% free 11717K/12268K, paused 3ms+5ms, total 32ms
D/jdwp:    sendBufferedRequest : len=0x34
W/Trace:    Unexpected value from nativeGetEnabledTags: 0
D/NativeCrypto: ssl=0x5ff7db18 NativeCrypto_SSL_do_handshake fd=0x20300005 shc=0x21a00009 timeout_millis=0 client_mode=1 npn=0x0
D/NativeCrypto: doing handshake ++
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x10 ret=1
D/NativeCrypto: ssl=0x5ff7db18 handshake start in UNKWN  before/connect initialization
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:UNKWN  before/connect initialization
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:23WCHA SSLv2/v3 write client hello A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1002 ret=-1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:error exit in 23RSHA SSLv2/v3 read server hello A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: doing handshake -- ret=-1
D/NativeCrypto: ssl=0x5ff7db18 NativeCrypto_SSL_do_handshake ret=-1 errno=11 sslError=2 timeout_millis=0
D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
D/NativeCrypto: doing handshake ++
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3RSH_A SSLv3 read server hello A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored

E/NativeCrypto: ssl=0x5ff7db18 cert_verify_callback x509_store_ctx=0x60098a40 arg=0x0
E/NativeCrypto: ssl=0x5ff7db18 cert_verify_callback calling verifyCertificateChain authMethod=RSA

D/NativeCrypto: ssl=0x5ff7db18 cert_verify_callback => 1
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3RSC_A SSLv3 read server certificate A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3RSD_A SSLv3 read server done A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3WCKEA SSLv3 write client key exchange A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/jdwp:    processIncoming
D/jdwp:    handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x400069E0, flags=0x0, dataLen=0x9
D/jdwp:    sendBufferedRequest : len=0x34
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3WCCSA SSLv3 write change cipher spec A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3WFINA SSLv3 write finished A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3FLUSH SSLv3 flush data
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1002 ret=-1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:error exit in 3RFINA SSLv3 read finished A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1002 ret=-1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:error exit in 3RFINA SSLv3 read finished A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: doing handshake -- ret=-1
D/NativeCrypto: ssl=0x5ff7db18 NativeCrypto_SSL_do_handshake ret=-1 errno=11 sslError=2 timeout_millis=0
D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
D/NativeCrypto: doing handshake ++
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1001 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:3RFINA SSLv3 read finished A
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x20 ret=1
D/NativeCrypto: ssl=0x5ff7db18 handshake done in SSLOK  SSL negotiation finished successfully
D/NativeCrypto: ssl=0x5ff7db18 info_callback calling handshakeCompleted
D/NativeCrypto: ssl=0x5ff7db18 info_callback completed
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x1002 ret=1
D/NativeCrypto: ssl=0x5ff7db18 SSL_connect:ok exit in SSLOK  SSL negotiation finished successfully
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
D/NativeCrypto: doing handshake -- ret=1
D/NativeCrypto: ssl=0x5ff7db18 NativeCrypto_SSL_get_certificate => NULL

D/MainActivity: connected

D/NativeCrypto: ssl=0x5ff7db18 sslWrite buf=0x41c08c50 len=16 write_timeout_millis=0
D/NativeCrypto: Doing SSL_write() with 16 bytes to go ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_write() with result 16, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: ssl=0x5ff7db18 sslRead buf=0x41c0e270 len=8192,timeo=0
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result -1, error code 2 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result 38, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: ssl=0x5ff7db18 sslWrite buf=0x41c08c50 len=15 write_timeout_millis=0
D/NativeCrypto: Doing SSL_write() with 15 bytes to go ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_write() with result 15, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: ssl=0x5ff7db18 sslRead buf=0x41c0e296 len=8154,timeo=0
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result -1, error code 2 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result 31, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0

D/MainActivity: login-status: true

D/NativeCrypto: ssl=0x5ff7db18 sslWrite buf=0x41c08c50 len=8 write_timeout_millis=0
D/NativeCrypto: Doing SSL_write() with 8 bytes to go ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_write() with result 8, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: ssl=0x5ff7db18 sslRead buf=0x41c0e2b5 len=8123,timeo=0
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result -1, error code 2 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result 20, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: ssl=0x5ff7db18 sslWrite buf=0x41c08c50 len=6 write_timeout_millis=0
D/NativeCrypto: Doing SSL_write() with 6 bytes to go ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_write() with result 6, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: ssl=0x5ff7db18 sslRead buf=0x41c0e2c9 len=8103,timeo=0
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result -1, error code 2 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result 46, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
I/System.out:    [CDS]connect[/meineIP:56629] tm:90
D/Posix:    [Posix_connect Debug]Process de.meine.app :56629
D/NativeCrypto: ssl=0x5ff7db18 sslWrite buf=0x41c08c50 len=52 write_timeout_millis=0
D/NativeCrypto: Doing SSL_write() with 52 bytes to go ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_write() with result 52, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: ssl=0x5ff7db18 sslRead buf=0x41c0e2f7 len=8057,timeo=0
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result -1, error code 2 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result 52, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
I/System.out:    [CDS]close[48049]
I/System.out:    close [socket][/0.0.0.0:48049]

D/MainActivity: Store File = false

D/NativeCrypto: ssl=0x5ff7db18 sslWrite buf=0x41c08c50 len=6 write_timeout_millis=0
D/NativeCrypto: Doing SSL_write() with 6 bytes to go ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_write() with result 6, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: ssl=0x5ff7db18 sslRead buf=0x41c0e32b len=8005,timeo=0
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result -1, error code 2 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: sslSelect type=READ fd=59 appData=0x5fd4e2d0 timeout_millis=0
D/NativeCrypto: sslSelect READ fd=59 appData=0x5fd4e2d0 timeout_millis=0 => 1
D/NativeCrypto: Doing SSL_Read() ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: Returned from SSL_Read() with result 14, error code 0 ssl=0x5ff7db18, appData=0x5fd4e2d0
D/NativeCrypto: ssl=0x5ff7db18 NativeCrypto_SSL_interrupt
D/NativeCrypto:  sslNotify, appData=0x5fd4e2d0 ret=1
D/NativeCrypto:  sslNotify, appData=0x5fd4e2d0 ret=1
D/NativeCrypto: ssl=0x5ff7db18 info_callback where=0x4008 ret=256
D/NativeCrypto: ssl=0x5ff7db18 SSL3 alert write:W:CN warning close notify
D/NativeCrypto: ssl=0x5ff7db18 info_callback ignored
I/System.out:    [CDS]close[51668]
I/System.out:    close [socket][/0.0.0.0:51668]

D/MainActivity: ausgelogt und getrennt
Code:
    public boolean toServerViaFtp(){

        boolean     successful = false;
        FTPSClient   mFTPSClient;

        Log.d( LOG_TAG , "toServerViaFtp - start" );

        try {

            // Verbinde mit Server
            mFTPSClient = new FTPSClient("SSL");
         
            KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
            kmf.init(null, null);
            KeyManager km = kmf.getKeyManagers()[0];
            mFTPSClient.setKeyManager(km);

            // connecting to the host
            mFTPSClient.connect("name.host.eu", 21);
            boolean status = mFTPSClient.login("uName", "Passw");
            Log.d( LOG_TAG , "login-status: " + status );
            // now check the reply code, if positive mean connection success
            if (FTPReply.isPositiveCompletion(mFTPSClient.getReplyCode())) {
              // Set File Transfer Mode
         
                mFTPSClient.setFileType(FTPSClient.BINARY_FILE_TYPE);
                mFTPSClient.enterLocalPassiveMode();
            }

            // Dateiupload
              //Context context = MainActivity.this;
            String srcFilePath = Environment.getExternalStorageDirectory() + "/Vertraege/Pool.pdf";
            String desFileName = "/Intenso-TwisterLine-01/VertraegeAPP/Pool.pdf";
              //FileInputStream srcFileStream = this.openFileInput(srcFilePath);
            FileInputStream srcFileStream = new FileInputStream(srcFilePath);
         
            status = mFTPSClient.storeFile(desFileName, srcFileStream);
            Log.d(LOG_TAG, "Store File = " + status);
         
            srcFileStream.close();

            // Verbindung schließen
            mFTPSClient.logout();
            mFTPSClient.disconnect();
            Log.d(LOG_TAG, "Verbindung getrennt");

            successful = true;

        } catch (IOException ioe) {
            ioe.printStackTrace();
            Log.d( LOG_TAG , "FEHLER: " + ioe );

        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            Log.d(LOG_TAG, "FEHLER: " + e);
        } catch (UnrecoverableKeyException urke) {
            urke.printStackTrace();
            Log.d(LOG_TAG, "FEHLER: " + urke);
        } catch (KeyStoreException kse) {
            kse.printStackTrace();
            Log.d(LOG_TAG, "FEHLER: " + kse);
        }

        return successful;

    }
 
Zuletzt bearbeitet:
Ich würde darauf tippen, dass es etwas simples ist.

- Kann vielleicht die lokale PDF-Datei nicht gelesen werden, weil der Pfad oder Dateiname falsch ist?
- Ist das ExternalStorageDirectory überhaupt verfügbar?
- Ist das ExternalStorageDirectory auch das, was du erwartest? (Vielleicht erwartest du die SD-Karte, es ist aber der externe Speicher, der im Gerät verbaut ist?)

Die Kommunikation mit dem FTP-Server über SSL scheint sauber zu funktionieren.
 
Ich vermute auch das es etwas simples ist. Nur was?
Das ExternalStorageDirectory zeigt ja auf den Standartspeicher, welcher bei mir die SD ist. Das Funktioniert auch. Ich habe auch über den selben Link die Datei erstellt und kann sie auch über diesen öffnen.
Habe auch mit .txt datei probiert - ist auch leer.

ich hab mir jetzt mal storeFile in der commons Bibliothek angesehen
Code:
private boolean __storeFile(int command, String remote, InputStream local)
throws IOException
{
    OutputStream output;
    Socket socket;

    if ((socket = _openDataConnection_(command, remote)) == null)
        return false;

    output = new BufferedOutputStream(socket.getOutputStream(),
            getBufferSize()
    );
    if (__fileType == ASCII_FILE_TYPE)
        output = new ToNetASCIIOutputStream(output);
    // Treat everything else as binary for now
    try
    {
        Util.copyStream(local, output, getBufferSize(),
                CopyStreamEvent.UNKNOWN_STREAM_SIZE, null,
                false);
    }
    catch (IOException e)
    {
        try
        {
            socket.close();
        }
        catch (IOException f)
        {}
        throw e;
    }
    output.close();
    socket.close();
    return completePendingCommand();
}
und hab schon fast die vermutung das beim ersten if (socket=_openDataConnection) was schief läuft.
oder das etwas konfiguriert werden muss. Hab dazu irgendwas irgendwo im Netz gelesen. zwecks zeit und ländereinstellungen.
 

Ähnliche Themen

AnnaBauer21
Antworten
0
Aufrufe
604
AnnaBauer21
AnnaBauer21
D
Antworten
8
Aufrufe
916
jogimuc
J
S
Antworten
7
Aufrufe
1.632
Silvasurf
S
AnnaBauer21
Antworten
6
Aufrufe
1.179
AnnaBauer21
AnnaBauer21
Zurück
Oben Unten