2011-06-20 19 views
0

は、私は以下のコードを使用してFTP経由で文字列を送信しようとしているばかりが、私はエラーを取得しています:は、FTP経由で文字列を送信:エラー

{ 

    //miscellaneous lines of code..... 
    //Convert contents of shopping cart into a property list 
    [Cart serializeCart]; 

    //now need to transport the propertyList to the webserver 
    //first step is get the serialized propertylist from the documents folder 
    NSString *pathToSerializedCart = [rootPath stringByAppendingPathComponent:@"serializedCart.plist"]; 

    NSString *shoppingCartString; 

    if (![fileManager fileExistsAtPath:pathToSerializedCart]) 
    { 
     NSLog(@"ERROR:\nCouldnt find serialized cart in documents folder."); 
    } 
    else 
    { 
     NSData *serializedData = [NSData   dataWithContentsOfFile:pathToSerializedCart]; 
     shoppingCartString = [[NSString alloc] initWithData:serializedData encoding:NSUTF8StringEncoding]; 
    } 

    NSLog(@"%@", shoppingCartString); 
    //Now that the cart is converted into a string. it is ready for transport 
    NSURL *url = [NSURL URLWithString:@"ftp://username:[email protected]/folder/serializedCart.xml"]; 

    BOOL OK =[shoppingCartString writeToURL:url atomically:NO encoding:NSUTF8StringEncoding error:&error]; 
    if(!OK) { 
     NSLog(@"Error writing to file %@ , error = %@", url, [error localizedFailureReason]); 
    } 

私はこのコードについて、次のコンソール出力を取得しています:変数の

Error writing to file ftp://username:[email protected]/folder/serializedCart.xml , error = (null) 

ワン:_domain最後の行で、このエラーオブジェクトで、私はデバッグ時に、それの上にマウスが私はトンデバッグするかどうかはわかりませんNSCocoaErrorDomain

語ります彼の 他に提案がありますか?

答えて

0

writeToURL:..のメソッドは、FTPプロトコルをサポートしていません。文字列コンテンツをftpサーバーに書き込むには、他のメカニズムを使用する必要があります。このようなアップロードを処理するには、ios-ftp-serverなどのツールをご覧ください。アップルのsample codeもご覧ください。

関連する問題