Re: [net] FTPClient doesn't download full images

2020-06-04 Thread Erwin Hogeweg
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

Re: Re: [net] FTPClient doesn't download full images

2020-06-04 Thread Robert Paasche
No never used with images. //length was "*2" but why? That is for an buggy ftp-server, which mishandled multibyte encodings. On UTF-16 Files he has reported the number of chars instead of bytes, so the file size was just the half erverytime. fos.write(data); this should be something like:

Re: Re: [net] FTPClient doesn't download full images

2020-06-04 Thread Julia Ruzicka
@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

AW: [net] FTPClient doesn't download full images

2020-06-04 Thread Julia Ruzicka
Hi everyone! I created a small test app that uses my "download" class on a button press (but doesn't do anything else) and did some more testing with it (with "FTP.BINARY_FILE_TYPE"): - Downloading a 14mb txt file (and its copies) always finishes with a complete file (even with a long file name)

Re: [net] FTPClient doesn't download full images

2020-06-04 Thread Robert Paasche
The following line is wrong: while ((len = bis.read(buf)) > 0) { //Same result using only 'is' read == -1 marks the end of the stream. 0 shows only that the stream is still waiting for the next chunk of data. Please read the JavaDocs: > Returns: > the number of bytes read, or -1 if the end

Re: [net] FTPClient doesn't download full images

2020-06-04 Thread Julia Ruzicka
Thanks for your reply! I changed the code and did the usual AndroidStudio restart/clean/build but most images are still downloaded incompletely. I don't know if my other answer (sent about an hour ago) came through (I did some more testing today), so here's an imgur album with test images and

Re: [net] FTPClient doesn't download full images

2020-06-04 Thread Robert Paasche
Hmm maybe it is the bufferdStream. That's working code I'm using in a project for years now: private FTPClient createClient() { FTPClient ftp = new FTPClient(); FTPClientConfig config = new FTPClientConfig(); config.setServerTimeZoneId("UTC");

Re: [net] FTPClient doesn't download full images

2020-06-04 Thread Gary Gregory
If you want to read a stream without dealing with low-level headaches, you can use https://commons.apache.org/proper/commons-io/javadocs/api-release/org/apache/commons/io/IOUtils.html Gary On Thu, Jun 4, 2020 at 6:53 AM Julia Ruzicka wrote: > Thanks for your reply! > > I changed the code and

Re: [net] FTPClient doesn't download full images

2020-06-04 Thread Christoph Läubrich
Don't know if the code you have showed is your original one but in general its not a good idea to "catch and ignore" exceptions, yo either: - simply buble up to the caller - wrap into other exceptions if required by the API - explicitly handle/document I'm using comons-ftp for large files and

Re: Re: [net] FTPClient doesn't download full images

2020-06-04 Thread Robert Paasche
@ julia.ruzicka content is just a simple POJO holding the byte and meta data (like timestamps). In some situations I'm using a fileoutputstream after disconnecting from ftp. I'm downloading large (>300 mb) zip-Files. Am Do., 4. Juni 2020 um 14:10 Uhr schrieb Julia Ruzicka <

Re: Re: [net] FTPClient doesn't download full images

2020-06-04 Thread Julia Ruzicka
@Robert Paasche At first I tried to do it with a `FileOutputStream` and `ftpClient.retrieveFile(fileName,fos)` but that's how I noticed the problem. I then switched to using ` InputStream is = ftpClient.retrieveFileStream(filename)` and when that didn't work properly either, I added `