How to ftp from the iPad/iPhone ?

Discussion in 'iPhone Tips, Help and Troubleshooting' started by zaxonus, Jan 30, 2011.

  1. zaxonus macrumors newbie

    Dec 23, 2010

    I am trying to write a simple iPad application and I am facing the following problem, can any one point what I am doing wrong ?

    I have a button bound to the following method (downLoad). When the button is pushed it should download a file (file.txt) from the internet.

    It is the first time I do ftp in an iOS program, I just tried to put together pieces of information I found on the net.
    So I might well have written nonsense. Please let me know. Is there a mistake in the code for the downLoad method I wrote ?
    There must be (some mistake) since the readCallBack function does not seem to be called.

    - (void) downLoad
    CFStringRef UpGrdURL=CFSTR("");
    CFURLRef requestURL=CFURLCreateWithString(kCFAllocatorDefault,UpGrdURL,NULL);
    CFURLRef requestLocalFile=CFURLCreateWithFileSystemPath(NULL, CFSTR("localFile.txt"),
    kCFURLPOSIXPathStyle, false);
    CFReadStreamRef readStream=CFReadStreamCreateWithFTPURL(kCFAllocatorDefault,requestURL);
    CFWriteStreamRef writeStream=CFWriteStreamCreateWithFile(kCFAllocatorDefault,requestLocalFile);
    CFWriteStreamOpen (writeStream);
    if (CFWriteStreamGetStatus(writeStream)==kCFStreamStatusOpen) {
    UIAlertView * alertView = [[UIAlertView alloc] initWithTitle: @"Information box."
    message: [NSString stringWithFormat:mad:"(CFWriteStreamOpen : kCFStreamStatusOpen."]
    delegate: nil cancelButtonTitle: @"OK" otherButtonTitles: nil];
    [alertView show];
    [alertView release];

    MyStreamInfo XX;
    CFStreamClientContext CTX = { 0, &XX, NULL, NULL, NULL };

    CFStringRef UserName=CFSTR("myusername");
    CFStringRef PassWord=CFSTR("mypassword");
    CFReadStreamSetProperty (readStream,kCFStreamPropertyFTPUserName,UserName);
    CFReadStreamSetProperty (readStream,kCFStreamPropertyFTPPassword,PassWord);
    CFReadStreamSetProperty (readStream,kCFStreamPropertyFTPUsePassiveMode,NO);
    // CFReadStreamOpen (readStream);

    void readCallBack(
    CFReadStreamRef stream,
    CFStreamEventType eventType,
    void *clientCallBackInfo)

    In my header file I have :

    #define kMyBufferSize 1024

    typedef struct MyStreamInfo {
    CFWriteStreamRef writeStream;
    CFReadStreamRef readStream;
    CFDictionaryRef proxyDict;
    SInt64 fileSize;
    UInt32 totalBytesWritten;
    UInt32 leftOverByteCount;
    UInt8 buffer[kMyBufferSize];
    } MyStreamInfo;

    Thanks in advance for any tip.
  2. saberahul macrumors 68040

    Nov 6, 2008
    There is a subforum specifically designed for programming apps and code. Posting there will provide some informative replies.
  3. zaxonus thread starter macrumors newbie

    Dec 23, 2010
    How to ftp from the iPad/iPhone ?

    This is a good information, but where is this subforum specifically designed for programming apps and code ? I did not see it.
  4. forum user macrumors regular

    Aug 28, 2008
  5. zaxonus thread starter macrumors newbie

    Dec 23, 2010

Share This Page