Hi,

I have no idea if this is related but I seem to remember from a life long, long 
ago that you can set up and FTP connection in two modes ASCII and binary. The 
default is (used to be) ASCII and when you feed  binary data through that 
connection then (some) non-ascii characters were translated.

Again, I may be talking complete nonsense here but it may be worth to check it 
out.

Cheers,

Erwin


> On Jun 4, 2020, at 09:29, Julia Ruzicka <julia.ruzi...@simutech.at> wrote:
> 
> @Robert Paasche
> 
> The code is used in an AsyncTask and there's more error handling to it 
> (including proper error messages,...), I just simplified it. ;)
> 
> Have you ever tested it with images too? Text files always seem to download 
> properly (no matter what size), it's just the images that are messed up.
> 
> Thanks for the code snippet, I just ran my app with it multiple times and the 
> files are all the right size, even the images, but no program is able to 
> actually open them, so not sure what's going on with that now:
> 
> if(singleFile.length > 0) { //check if file exists
>    String localPath = localFolder + File.separator + filename;
>    FTPFile single = singleFile[0];
>    InputStream inStream = ftpClient.retrieveFileStream(filename);
>    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
> 
>    int nRead;
>    byte[] data = new byte[(int) (single.getSize())]; //length was "*2" but 
> why?
> 
>    while ((nRead = inStream.read(data, 0, data.length)) != -1) {
>        buffer.write(data, 0, nRead);
>    }
> 
>    buffer.flush();
>    inStream.close();
> 
>    FileOutputStream fos = new FileOutputStream(localPath);
>    fos.write(data);
>    fos.flush();
>    fos.close();
> 
>    if(ftpClient.completePendingCommand()) {
>        Log.d(TAG,"DONE");
>    } else {
>        Log.d(TAG,"NOT DONE");
>    }
> } 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to