将文件上传到ftp - iOS

时间:2012-05-18 11:41:11

标签: ios ftp

我使用SimpleFTPSample上传文件,但我遇到行问题:

ftpStream = CFWriteStreamCreateWithFTPURL(NULL, (__bridge CFURLRef) urlOfHost);
        assert(ftpStream != NULL);

它总是空的,我不知道为什么? hostUrl没问题,但没有任何事情发生在ftpStream上,我得到了断言。

URL:

urlOfHost = [[AppDelegate sharedAppDelegate] smartURLForString:[NSString stringWithFormat: @"ftp://wd150.1host.co.il/%@", orderKey]];

    success = (urlOfHost != nil);

    if (success) {
        // Add the last part of the file name to the end of the URL to form the final 
        // URL that we're going to put to.

        urlOfHost = CFBridgingRelease(CFURLCreateCopyAppendingPathComponent(NULL, (__bridge CFURLRef) url, (__bridge CFStringRef) [filePath lastPathComponent], false)
                                 );
        NSLog (@"%@", [urlOfHost description]);
        success = (urlOfHost != nil);
    }

有人知道吗?

提前感谢。

1 个答案:

答案 0 :(得分:0)

你是否在PutController中将这个药水添加到你的迁移程序中。以下将解决simpeFTPsample“文件读取错误”

@implementation PutController{    
     uint8_t   _buffer[kSendBufferSize];    
}        
 -(uint8_t *)buffer{        
 return self->_buffer;    
}

如果您未在程序中插入此部分。

 bytesRead = [self.fileStream read:self.buffer maxLength:kSendBufferSize];