【问题标题】:Upload bulk image in background thread在后台线程中上传批量图像
【发布时间】:2012-05-24 16:52:42
【问题描述】:

我想知道我们如何在 iPhone 中使用带有后台线程或进程的 web 服务上传大量图像。我在我的 iPhone 应用程序中存储大量图像,我想使用 .net 网络服务上传(发布)这些图像。现在,我正在使用 Web 服务发布单个图像,但我想在后台进程中发布多个图像。请帮助我,我将不胜感激。

【问题讨论】:

    标签: iphone image web-services upload


    【解决方案1】:

    我认为您需要使用 ASIHTTP 请求来异步调用服务器并将多个图像存储到服务器上。

    对于该方法在此方法之后的实现,用于上传图像。

    - (IBAction)btnPostImages_Clicked:(id)sender {
    
         if ([arrImages count] > 0) {
                   NSString *strURL = @"Write Your URL Here.";
                   ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:strURL]];
                   [request setDelegate:self];
                   [request setPostValue:@"This is sample text..." forKey:@"text"];
                   for (int i = 0; i < [arrImages count]; i++) {
                             [request addData:[arrImages objectAtIndex:i] withFileName:@"image.jpg" andContentType:@"image/jpeg" forKey:[NSString stringWithFormat:@"image%d", i + 1]];
                   }
    [request startAsynchronous];
         }
         else {
                  UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"Message" message:@"Please select images..." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
                [alertView show];
                [alertView release];
        }
    }
    

    您也可以按照本教程来实现 ASIHttp As Asynchronous

    Reference Url Here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-23
      • 2017-03-03
      • 2014-07-17
      • 1970-01-01
      • 2011-04-23
      • 1970-01-01
      • 2011-11-17
      • 1970-01-01
      相关资源
      最近更新 更多