0

My app is needing the ability to get multiple images from a web server / directory (i.e. www.somedomain.com/images/). The number of images will never be the same, and I will not have access to the names of the files because they will also never be the same. The end result I'm looking for is to give my client the ability to just access her sub directory through her ftp client and just drop images into the specified folder without having to name the images a certain name, write any xml files, or any other steps beyond dragging the images into the folder. Then my clients users that log into the app will be able to get the images that my client has placed into that directory. I have been looking into Apple's simpleFTPsample project to get access via FTP. I just want to know if there are any other simpler options? One reason being: simpleFTPsample style requires an FTP username and password to access those files. I'm not 100% sure if it is safe to place the user and pass within the app. Any suggestions or samples would be great thanks.

4

2 に答える 2

0

画像の使用方法に基づいて、おそらく最善の策は、画像と対応するURLを提供するWebサービスを作成することです。これにより、クライアントのユーザーがFTPについて何も知らなくても画像を取得し、特定の1つまたは複数のディレクトリの画像のみを表示できるようにするソリューションが提供されます。この設定により、応答に基づいて画像を読み込み、必要に応じて使用できるようになります。これは、テーブルビューセルに画像を非同期的にロードするためのサンプルコードの一部です。

// load thumbnail images off main thread
    dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
        // backgroung processing
        UIImage *thumbnail = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"yourURL"]]];

        dispatch_async( dispatch_get_main_queue(), ^{
            // background processing complete
            [[(TableCell *) cell image] setImage:thumbnail];
            [[cell activityIndicator] stopAnimating];

            // if row selected before image loaded 
            if ([indexPath row] == [[tableView indexPathForSelectedRow] row]) {
                 if (!iPhone) {
                     [myButton setBackgroundImage:thumbnail forState:UIControlStateNormal];
                 }
             }
        });
    });

https://github.com/propstm/SampleWeatherAppのgithubで利用できるサービス応答を設計するのに役立つサンプルWebサービスプロジェクトを作成しました

于 2012-12-10T21:47:16.317 に答える
0

画像を一覧表示する単純なPHPスクリプトを画像と同じHTMLディレクトリに配置することをお勧めします。次に、リストスクリプトを押した結果に基づいて、単純なNSURLConnection呼び出しを使用して、ディレクトリ内のすべての画像をダウンロードできます。

このようなもの。

<?php

    $directory = "."; // Use your directory here

    // create a handler for the directory
    $handler = opendir($directory);

    // open directory and walk through the filenames
    while ($file = readdir($handler)) {

      // if file isn't this directory or its parent, add it to the results
      if ($file != "." && $file != "..") {
        echo "$file\n";
      }

    }

    // tidy up: close the handler
    closedir($handler);
?>

何らかのセキュリティがある場合は、ディレクトリで.htaccessを使用してログインバリアを提供し、NSURLConnectionを使用して資格情報を提供できます。

幸運を。

于 2012-12-10T22:02:30.263 に答える