2

I'm currently facing a problem when downloading some files from an FTP server: they become corrupt. An introduction to the problem may be seen in this SO question (when I was thinking the problem was with my Qt-based software, while now I'm convinced it is on the server).

The situation is this: I want to copy 8 files to an FTP server and download them later using a Qt-based software with QNetworkAccessManager. In my attempts to do so, I discovered that allways 3 of the 8 files get corrupted (using both hash verification a.w.a. file size) in the same way (same erroneous file size). The problem is not with my software: downloading the files usign both Mozilla and Chrome results in the exact same errors. The entire process is as follows:

  1. 8 files are in a Linux Ubuntu folder. File sizes OK.
  2. The 8 files are transferred to Windows 7 folder.
  3. The files are send to the FTP server using FileZilla. Once finished, FileZilla tells the correct sizes for each of the 8 files.
  4. Files are downloaded both in Linux Ubuntu a.w.a. in Windows using both browsers and Qt-based app with QNetworkAccessManager. In Windows files are also downloaded with FileZilla.
  5. The same 3 files get corrupted - verified by the different sizes.

After discussing the problem in that SO question, it was suggested the problem could be server-sided. I did some research on the web and I found this, this and this. The suggestions would be different size calculation by FileZilla (difficult since I'm using Windows and Linux size calculation most of the time) and the "binary-or-ASCII transfer problem".

Regarding the second, I also find hard to believe this is the case because although 2 of the 3 problematic files are softwares and the other is a binary file, there is a fourth file which is also a binary and that shows no problem whatsoever. (and other 3 files are compressed .tar.gz wich I suppose are also binaries and, yet, they are downloaded corectly)

But lets suppose that was the case: I have to specify one of the two methods for the download. Well how could I do this both when downloading via Browser as well as when downloading via QNetworkAccessManager?

And what if this is not the case: then what is happening?

2
  • 1
    Your post is incomplete. You have written (difficult since
    – Dave
    Jun 8, 2015 at 12:34
  • @Dave It doesn't work fine using just FileZilla - and the problem also appears when using the browser for download, so it's definitively not a problem just with the Qt app.
    – Momergil
    Jun 8, 2015 at 13:28

1 Answer 1

4

Well it's seems we managed to find the problem - and it was, after all, the ASCII-or-binary issue.

When the problem first appeared, we were sending the files to the FTP server via FileZilla with transfer mode "auto". When downloading with FileZilla, the transfer was also set in "auto" and we got problems. The transfer mode used by the browser and by Qt's QNetworkAccessManager is unknown and both were returning with problems.

So my team tested downloading with FileZilla using binary; fail. We then downloaded using ASCII - success. So now we deleted the files in the server and uploaded one of the problematic with ASCII and downloaded it using FileZilla with ASCII as well - success. We then uploaded it using binary and downloaded using binary using FileZilla - success. But when downloading with my Qt-based app - fail. So we guessed that QNetworkAcessManager downloads using ASCII which means either I have to reconfigure it to download as binary or upload the files to the FTP server using ASCII. Since this later option will get me problems when calculating the file size, we are going for the first solution if possible. (We also successfully downloaded with the browser which seems to do it with binary).

So that's it: it seems QNetworkAccessManager downloads using ASCII and, therefore, any file uploaded to an FTP Server needs to be done so in ASCII if that is supposed to be later downloaded using QNetworkAcessManager.

EDIT: A mistake on my part. QNetworkAccessManager actually downloads using binary, not ASCII. This, of course, leads me with having to re-evaluate my interpretation on how to solve the problem, but it is still clear that the ASCII-or-binary is the cause of all the mess.

EDIT 2: Problem solved. Essentially what one has to do is to ensure that the data will be uploaded as binary to the FTP server; since QNAM downloads as binary, the data should be fine. Funny thing is: this seams to only work under Linux. If I run the Qt-based download app in Windows, the problem persists.

EDIT 3: Problem in Windows solved: it was a configuration issue, not related to this problem.

3
  • 1
    Why not use WinSCP? It is scriptable and works in the manner you suggest.
    – Leptonator
    Aug 21, 2015 at 13:10
  • @Leptonator thanks for the tip, I wasn't aware of the existence of this app. Nevertheless FileZilla works fine now that I understand the problem I had (supposing you're suggesting usin WinSCP instead of FileZilla).
    – Momergil
    Aug 25, 2015 at 17:07
  • 1
    I like FileZilla, but since WinSCP is based on it and Martn (the Developer) has made is scriptable, it is way better than FileZilla..
    – Leptonator
    Aug 25, 2015 at 17:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .