BlitzMax FTP and small files

BlitzMax Forums/BlitzMax Beginners Area/BlitzMax FTP and small files

Hezkore(Posted 2008) [#1]
I'm trying to make my program to automatically download a few files from my FTP using some code I found in the Code Archives (http://www.blitzmax.com/codearcs/codearcs.php?code=2090)

It seems to work, I can download MP3 and images and everything, but if the file is small, like a TXT file... the file just shows up empty.
Any ideas what's causing it?


Perturbatio(Posted 2008) [#2]
You might need to post some code (sans-username/password), it'll make helping you easier.


Dirk Krause(Posted 2008) [#3]
One possible explanation is that the file doesn't exist on the server. Then the program fails, probably unnoticed (check the last line of the output) and leaves an empty file.


Perturbatio(Posted 2008) [#4]
One possible explanation is that the file doesn't exist on the server.


Or perhaps that you don't have permissions to access it


Dabhand(Posted 2008) [#5]
You could always use Wininet:-

http://msdn2.microsoft.com/en-us/library/aa385483.aspx

Baring in mind, its a windows only affair! This works really well with other Blitz languages, but havent tried using it in max yet.


Hezkore(Posted 2008) [#6]
The code I'm using is exactly what is found in the code archive: http://www.blitzmax.com/codearcs/codearcs.php?code=2090

Doing all the stuff that comes with the code (renaming, download MP3 etc.) works fine, small files is the only problem.
If I make a TXT file and write "Hello" in it and download it with BlitzMax I just get an empty file, but I can download it with any other FTP client just fine! but if I spam the TXT with "Hello" a million times making the file larger, it works with both the BlitzMax code and a normal client.
And it shouldn't be a permission problem or anything like that... The server itself is working fine and doesn't accept anonymous connections, so I know the login part works.
And the file does exist, I've created 3 files to test with Test.Mp3, Test.Png and Test.Txt they're all placed in the same place and accessed by the same user, the MP3 and PNG works fine with BlitzMax, It's just the small TXT that's the problem. I've tried making the PNG smaller and the same problem happens there, if the file is too small it will just be downloaded as an empty file.
There are no errors in either the Client or Server, in fact... the server tells me the file was fully downloaded!
And I'd like this to work on both Mac and PC.


Brucey(Posted 2008) [#7]
Could be an issue with CopyStream()...

DebugStop/Log might be your friend here.

Otherwise, there are probably modules available which are designed to take the stress out of doing things like this :-)


TomToad(Posted 2008) [#8]
I don't see a CloseStream(Filestream) in the getDataAsFile() function. My guess is that small files are being buffered, and then lost when the Function ends. Technically, CloseStream should be implicitly called when FileStream loses scope, but you might want to go ahead and place an explicit CloseStream() after the CopyStream() to flush the buffer and write the contents to the HD.