FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

FTP file download and upload using login and password

 
Post new topic   Reply to topic     Forum Index -> Juno
View previous topic :: View next topic  
Author Message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Mon Feb 01, 2010 11:07 pm    Post subject: FTP file download and upload using login and password Reply with quote

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
View user's profile Send private message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Mon Feb 01, 2010 11:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Wed Feb 03, 2010 11:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
Numpsy



Joined: 22 Aug 2009
Posts: 27

PostPosted: Fri Feb 05, 2010 12:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Fri Feb 05, 2010 12:21 pm    Post subject: Reply with quote

The upload works for me. Here is the dmd version:
Quote:
0:10:33.53>dmd
Digital Mars D Compiler v1.046
Copyright (c) 1999-2009 by Digital Mars written by Walter Bright
Documentation: http://www.digitalmars.com/d/1.0/index.html


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. Sad

Any help would be greatly appreciated.

thanks,

jose
Back to top
View user's profile Send private message
Numpsy



Joined: 22 Aug 2009
Posts: 27

PostPosted: Fri Feb 05, 2010 4:58 pm    Post subject: Reply with quote

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
View user's profile Send private message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Fri Feb 05, 2010 6:27 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Juno All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group