3

White Raccoon と Black Raccoon の両方を使用して、FTP サーバーに zip ファイルをアップロードしました。White Raccoon では、zip ファイルをアップロードできませんでした。常に serverTimeout エラーが発生します。ということで、白いアライグマで通常のxmlファイルをアップロードしようとしたら、データなし(0バイトサイズ)のファイルがアップロードされてしまいました。ここにコードがあります

-(void)upload:(NSData*)data{
   
//the upload request needs the input data to be NSData
NSData * ourImageData = data;

//we create the upload request
//we don't autorelease the object so that it will be around when the callback gets called
//this is not a good practice, in real life development you should use a retain property to store a reference to the request
WRRequestUpload * uploadImage = [[WRRequestUpload alloc] init];
uploadImage.delegate = self;

//for anonymous login just leave the username and password nil
uploadImage.hostname = @"hostname";
uploadImage.username = @"username";
uploadImage.password = @"password";

//we set our data
uploadImage.sentData = ourImageData;

//the path needs to be absolute to the FTP root folder.
//full URL would be ftp://xxx.xxx.xxx.xxx/space.jpg
uploadImage.path = @"huge_test.zip";

//we start the request
[uploadImage start];
}

私はこれを使用しています https://github.com/valentinradu/WhiteRaccoon

-WhiteRaccoon が機能しないため、BlackRaccoon を試しましたが、通常の xml ファイルをアップロードすることさえできず、「サーバーからの応答なしでストリームがタイムアウトしました」というエラーが表示されます。

ここにコードがあります

- (IBAction) uploadFile :(NSData *)datas{

self.uploadData = [NSData dataWithData:datas];

 //Here I am just Checking that DATA come from another method is proper or not. I got All thedata which I have passed from method
    NSString  *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/test12121.xml"];
    // Write the data to file
[datas writeToFile:path atomically:YES];
    self.uploadFile = [[BRRequestUpload alloc] initWithDelegate: self];

//----- for anonymous login just leave the username and password nil
self.uploadFile.path = @"/test.xml";
self.uploadFile.hostname = @"hostname";
self.uploadFile.username = @"username";
self.uploadFile.password = @"password";
//we start the request
[self.uploadFile start];

}

- (long) requestDataSendSize: (BRRequestUpload *) request{

 //----- user returns the total size of data to send. Used ONLY for percentComplete
 return [self.uploadData length];

}

 - (NSData *) requestDataToSend: (BRRequestUpload *) request{

 //----- returns data object or nil when complete
 //----- basically, first time we return the pointer to the NSData.
 //----- and BR will upload the data.
 //----- Second time we return nil which means no more data to send
 NSData *temp = self.uploadData;   // this is a shallow copy of the pointer

 self.uploadData = nil;            // next time around, return nil...

 return temp;

 }

  -(void) requestFailed:(BRRequest *) request{

  if (request == uploadFile)
  {
    NSLog(@"%@", request.error.message);
    
    uploadFile = nil;
 }
   NSLog(@"%@", request.error.message);
  }

  -(BOOL) shouldOverwriteFileWithRequest: (BRRequest *) request
   {
  //----- set this as appropriate if you want the file to be overwritten
  if (request == uploadFile)
  {
    //----- if uploading a file, we set it to YES
    return YES;
  }

   //----- anything else (directories, etc) we set to NO
   return NO;
  }

  - (void) percentCompleted: (BRRequest *) request
    {
   NSLog(@"%f completed...", request.percentCompleted);
  }

  -(void) requestCompleted: (BRRequest *) request
  {
  //----- handle Create Directory
  if (request == uploadFile)
  {
    NSLog(@"%@ completed!", request);
    uploadFile = nil;
 }

 }

https://github.com/lloydsargent/BlackRaccoonを使用しています。

タイムアウト制限を 60 まで変更しましたが、うまくいきません。誰か助けてください?zipファイルをFTPサーバーにアップロードする別の方法を知っている人がいたら、教えてください。

前もって感謝します。

4

0 に答える 0