View previous topic :: View next topic |
Author |
Message |
jicman
Joined: 22 Dec 2004 Posts: 298 Location: Rochester, NY
|
Posted: Mon Feb 01, 2010 11:07 pm Post subject: FTP file download and upload using login and password |
|
|
Greetings.
I have this small program,
Code: |
import juno.net.core,
juno.net.client,
std.stdio;
void main() {
auto remoteUri = new Uri(r"ftp://NSA:nsa@localhost/test.txt");
writefln(remoteUri.scheme());
writefln(remoteUri.userInfo());
try
{
downloadFile(remoteUri,"c:\\zzz.txt");
}
catch (NetException e)
{
writef("ERROR: ");
writefln(e);
}
}
|
When I run it, I get,
Quote: | ftp
NSA:nsa
ERROR:
|
I would like to be able to download and upload a file using FTP. Can you tell me what am I doing wrong?
thanks,
jose |
|
Back to top |
|
|
jicman
Joined: 22 Dec 2004 Posts: 298 Location: Rochester, NY
|
Posted: Mon Feb 01, 2010 11:15 pm Post subject: |
|
|
By the way, here is the log for the FTP server:
Quote: | Mon 01 Feb 2010 [23:57:36] 000006 User connecting, IP:127.0.0.1
Mon 01 Feb 2010 [23:57:36] 000006 220 CesarFTP 0.99g Server Welcome !
Mon 01 Feb 2010 [23:57:36] 000006 USER NSA
Mon 01 Feb 2010 [23:57:36] 000006 User NSA connected, login : NSA
Mon 01 Feb 2010 [23:57:36] 000006 331 User login OK, waiting for password
Mon 01 Feb 2010 [23:57:36] 000006 PASS **********
Mon 01 Feb 2010 [23:57:36] 000006 User NSA logged in successfully
Mon 01 Feb 2010 [23:57:36] 000006 230 User password OK, CesarFTP server ready
Mon 01 Feb 2010 [23:57:36] 000006 TYPE I
Mon 01 Feb 2010 [23:57:36] 000006 200 Type successfully set
Mon 01 Feb 2010 [23:57:36] 000006 PASV
Mon 01 Feb 2010 [23:57:36] 000006 227 Entering Passiv Mode (127,0,0,1,8,5)
Mon 01 Feb 2010 [23:57:36] 000006 SIZE /test.txt
Mon 01 Feb 2010 [23:57:36] 000006 213 27
Mon 01 Feb 2010 [23:57:36] 000006 RETR /test.txt
Mon 01 Feb 2010 [23:57:36] 000006 User NSA retrieves /test.txt
Mon 01 Feb 2010 [23:57:36] 000006 150 Data connection created for /test.txt retrieving
Mon 01 Feb 2010 [23:57:36] 000006 226 Successful transfer |
so, it appears to be working. I have also tried another unix server and the same thing happens.
Thanks for the help.
jose |
|
Back to top |
|
|
jicman
Joined: 22 Dec 2004 Posts: 298 Location: Rochester, NY
|
Posted: Wed Feb 03, 2010 11:15 pm Post subject: |
|
|
Does any body has any idea? I need to programmatically upload and download a file to an FTP site. I want to use Juno libraries or if there are any others. And by the way, the upload is working perfectly, so I am able to FTP a file to the same spot and the same FTP directory, same user and password. However, I can not do the downloadFile.
Any ideas?
thanks.
jose |
|
Back to top |
|
|
Numpsy
Joined: 22 Aug 2009 Posts: 27
|
Posted: Fri Feb 05, 2010 12:13 pm Post subject: |
|
|
What version of DMD are you using ?
When i try it with 1.056, i get an exception thrown inside Juno before main() is even called (looks like something odd going on with static constructors). |
|
Back to top |
|
|
jicman
Joined: 22 Dec 2004 Posts: 298 Location: Rochester, NY
|
Posted: Fri Feb 05, 2010 12:21 pm Post subject: |
|
|
The upload works for me. Here is the dmd version:
so, it looks like it is trying to write to a directory that does not exists. Weird. I was going to take a trace and try to figure it out, but time is not on my side, which I am sure it is also for other folks.
Any help would be greatly appreciated.
thanks,
jose |
|
Back to top |
|
|
Numpsy
Joined: 22 Aug 2009 Posts: 27
|
Posted: Fri Feb 05, 2010 4:58 pm Post subject: |
|
|
I got it running and found that it was throwing an error from
DownloadBitsCallback.OnStopBinding()
in client.d, as the hresult parameter was set to INET_E_DATA_NOT_AVAILABLE.
After looking at the MS docs @ http://msdn.microsoft.com/en-us/library/ms775130(VS.85).aspx, i tried changing the
DownloadBitsCallback.GetBindInfo()
function to set grfBINDF to just BINDF_GETNEWESTVERSION instead of BINDF_NOWRITECACHE and that seems to have made it work.
I've never used this Moniker stuff before though, so i don't know if that will break anything else. |
|
Back to top |
|
|
jicman
Joined: 22 Dec 2004 Posts: 298 Location: Rochester, NY
|
Posted: Fri Feb 05, 2010 6:27 pm Post subject: |
|
|
Yep. That worked for me too. for now, this is good. One thing that Juno should have is an FTP and HTTP libraries. I know that Tango has it, but I have too much code with
thanks,
jose |
|
Back to top |
|
|
|