FTP upload

Discussion in 'Programmer's Corner' started by Eric007, Aug 15, 2017.

  1. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,154
    39
    Hi All,

    I am doing some tests uploading some recorded audio (.3gp) to an FTP server and see if the upload functionality works but I am getting this error "Server returned an error: 553 Could not create file."

    I am using this https://www.swfwmd.state.fl.us/data/ftp/ for testing.

    It's a small xamarin app and here the url and credentials used. I think it connect fine but cannot upload.
    What could be the problem? the file format? or... any other good ftp Server I can test on?

    Code (Text):
    1.  
    2. string FtpUrl = [URL]ftp://ftp.swfwmd.state.fl.us[/URL];
    3. string UserName = "anonymous";
    4. string Password = "myemail";
    5.  
    Any help/guidance will be appreciated.
    Eric
     
  2. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,154
    39
    Now I am getting the error : "Request timed out"
    with the url:
    string FtpUrl = "ftp://ftp.swfwmd.state.fl.us/pub/in";
     
  3. wayneh

    Expert

    Sep 9, 2010
    16,001
    6,090
    Can you perform the upload using normal FTP software on a computer? I’m just suggesting you eliminate as many variables as you can.
     
  4. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,154
    39
    I tried using FileZilla to connect but got the attached error after 20 seconds.
     
  5. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,154
    39
    By the way I am not sure if this is how I should do this! I'm still trying to figure out the right way, ie how to send an audio file together with some other info (name,...) to an ftp server.
     
  6. wayneh

    Expert

    Sep 9, 2010
    16,001
    6,090
    Well you obviously need to fix your connection problem before you can test your upload scheme.

    If the file format of the file you want to send does not already support metadata, you might consider archiving a small file with the metadata into a zip file with the audio file, and then unzip it at the other end.
     
  7. WBahn

    Moderator

    Mar 31, 2012
    23,952
    7,419
    How big is the file you are trying to upload? If it is large, try with a very small file using commercial software. If that works (and works with your code) then the problem is somehow related to large files, perhaps exceeding quotas or a connection time limit of some kind. If it doesn't work, then the problem is more fundamental than that, possibly an access privilege or transfer mode issue. If it works with the commercial software but not with your code, then at least part of the problem is with your code.
     
  8. vpoko

    Active Member

    Jan 5, 2012
    267
    51
    Regarding the first error, does the anonymous user have write permissions to the target directory?

    Regarding the time-out, are you (the client) behind a firewall or NAT router? FTP has two modes, active and passive. In active mode, the client first establishes a control channel but the server then connects to the client for the data transfer. FTP also supports a passive mode, where the client opens both connections. If you're behind a NAT router or firewall and don't want to mess with port triggering, your best bet is to go passive. See http://slacksite.com/other/ftp.html
     
    spinnaker likes this.
  9. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,154
    39
    @WBahn My little app records and upload the file. It's just a few seconds... will measure its size and let you know soon.
    @vpoko My app connects to the internet via my router wifi. Yes I have set it to passive.

    Here's a bit of code.

    Code (Text):
    1.  
    2. ...
    3. FtpWebRequest request = (FtpWebRequest)WebRequest.Create(FtpUrl);
    4. request.Method = WebRequestMethods.Ftp.UploadFile;
    5.  
    6. request.Credentials = newNetworkCredential(UserName, Password);
    7. request.KeepAlive = true;
    8. request.UseBinary = true;
    9. request.UsePassive = true;
    10. ...
    11.  
    Anybody can suggest another free Server I can connect to?

    Thanks
     
  10. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,154
    39
    I found another FTP Server for testing... I been able to connect using FileZilla and now I am testing now with my app.
     
  11. Eric007

    Thread Starter Senior Member

    Aug 5, 2011
    1,154
    39
    @WBahn 15 seconds recording id about 32429 Bytes

    And now I'm getting the error: Server returned an error: 500 'STOR' not understood
     
  12. wayneh

    Expert

    Sep 9, 2010
    16,001
    6,090
    So you sent it a STOR command it did not understand. Did you include the filename in the STOR command?
     
  13. MrSoftware

    Senior Member

    Oct 29, 2013
    1,327
    407
    Filezilla will show you the commands that it uses on the console. Also Windows has a built in ftp client (command line) you can use, though I'm not sure off-hand how to tell exactly what commands are being sent behind the scenes...but anyway, try filezilla with verbose logging and look at the commands going back and forth, then see if your software is replicating that. And if not, try to understand the differences.
     
    Eric007 likes this.
  14. vpoko

    Active Member

    Jan 5, 2012
    267
    51
    Make sure you're specifying the target filename on the server, not just the URL to the server or a path to the target directory.
     
    Eric007 likes this.
  15. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    7,815
    3,615
    Still haven't see any real code.
     
  16. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    7,815
    3,615

    Highly likely that anonymous cannot write to the directory.

    And Florida would have to be insane if they allowed clear text for file upload. You will likely need to use ftps at the very minimum.
     
  17. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    7,815
    3,615
    Been a long time since I coded for ftp but I don't ever recall having to wrap the server name in the url tag.

    string FtpUrl = ftp://ftp.swfwmd.state.fl.us;

    Where did you get this? Are you certain this is correct?
     
  18. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    7,815
    3,615

    I have never heard of STOR, just looked it up and looks like it is the same a PUT. Try PUT instead of STOR. STOR might not be supported across all platforms. Does not look like it is supported under DOS.
     
  19. bertus

    Administrator

    Apr 5, 2008
    19,389
    3,917
    Eric007 likes this.
  20. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    7,815
    3,615
    Eric007 likes this.
Loading...