unable to read file from ftp in android?

后端 未结 2 1168
Happy的楠姐
Happy的楠姐 2021-01-17 03:36

I am trying to read data from a file from ftp server. This piece of code works perfectly in java when i run from my desktop computer. I copied over the same code to android

2条回答
  •  北海茫月
    2021-01-17 04:35

    Error 550 usually means "permission error", so the most likely cause is username/password mismatch (but see case #3).

    Yet, if the same code works on your desktop, username and password ought to be correct. The possibilities I see are:

    • The package you are using is not the same between desktop and Android, and the Android version does not parse correctly username/password. Try sniffing the FTP traffic, or change FTP server address to a FTP server that you control (you can temporarily deploy one on your desktop), and verify whether username and password are transmitted correctly.
    • There is a DNS error and your desktop (or your Android) is not connecting to ftp.mysite.x10.mx but to somewhere else, e.g. a development installation on localhost (I did this once; took me some time to figure it out). Try changing the server name to its IP address.
    • As case (1), but the parsing error is caused by the TYPE I specification (";type=i" at end of URL) that the Android package does not recognize while the desktop one does. Should give a 500 Error, not 550; but several servers use error 550 to indicate file not found, and the package is believing that the file you want is 'sg1996text.txt;type=i' instead of 'sig1996text.txt'. Remove ';type=i' and see what happens.

提交回复
热议问题