1

iPhoneを使用してWebサーバーでファイルをZip/UnZipしてそのファイルを使用することは可能ですか?

もしそうなら、どうすればそれができるか教えてください。

私の問題は、 Webサーバーからローカルフォルダーをアップロード/ダウンロードしたいこと です。最初にローカルフォルダーを圧縮してから、Webサーバーからアップロードします..

Zipを作成してフォルダをアップロード/ダウンロードするのは正しい方法ですか?

4

3 に答える 3

1

-(void)updateFromInternet

{{

progressView.progress = 0;

//save to a temp file
NSString* updateURL = @"http://www.touch-code-magazine.com/wp-content/uploads/2010/06/LargeAppUpdate.zip";
NSLog(@"Checking update at : %@", updateURL);

progressView.hidden = NO;
responseData = [[NSMutableData alloc] init];

NSURLRequest* updateRequest = [NSURLRequest requestWithURL: [NSURL URLWithString:updateURL]];
NSURLConnection* connection = [[NSURLConnection alloc] initWithRequest:updateRequest delegate:self];
[connection start];

NSLog(@ "ダウンロード開始...");

}

質問がある場合は、このリンクを確認してください

http://www.touch-code-magazine.com/update-dynamically-your-iphone-app-with-new-content/

于 2012-08-03T13:08:42.590 に答える
1

最後にその終わり。RecursionFunction を使用すると、これは完了します... フォルダーを圧縮/解凍する必要はありません..

-(void)recursiveMethod:(NSString *)strPath {

[client1 initWithHost:@"HostName" username:self.username password:self.password];
NSArray *listFiles = [[NSArray alloc]init];


//Fetching data from document directory.
//    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
//    
//    // Get documents folder
//    NSString *docDir  = [paths objectAtIndex:0];


NSFileManager *fm = [NSFileManager defaultManager];
if ([fm fileExistsAtPath:strPath isDirectory:&isDir] && isDir)
{
    subpaths = [fm subpathsAtPath:strPath];
}
listFiles = [fm contentsOfDirectoryAtPath:strPath error:nil];
NSLog(@"listFiles ==== %@",listFiles);

for(int j=0; j < [listFiles count] ;j++)
{
//Check For Folder

if([[listFiles objectAtIndex:j]rangeOfString:@"."].location == NSNotFound)
    {

    self.folderName = [self.folderName stringByAppendingPathComponent:[listFiles    objectAtIndex:j]];

 //Create Current Folder 
[client1 createCollection:self.folderName];
 self.countItemsInFolder = 0; //countItemsInFolder is int(counter) 

//call recursiveMethod again
strPath = [strPath stringByAppendingPathComponent:[listFiles objectAtIndex:j]];
        [self recursiveMethod:strPath];
        self.folderName = [self.folderName stringByDeletingLastPathComponent];
        strPath = [strPath stringByDeletingLastPathComponent];
    }
    else
    {
        //upload Files
        self.countItemsInFolder = j+1;
        [self appdelegate].remoteFolderForUpload = self.folderName;
        NSString *destiFilePath = [strPath stringByAppendingPathComponent:[listFiles objectAtIndex:j]];
        [client1 uploadFile:[listFiles objectAtIndex:j] toPath:self.folderName fromPath:destiFilePath];
    }

}

if([listFiles count] == self.countItemsInFolder)
{
    strPath = [strPath stringByDeletingLastPathComponent];
}
}
于 2012-08-03T13:12:34.353 に答える
0

ダウンロード - サーバーから zip をダウンロードして解凍します。

アップロード - miniZip を使用してデバイス上のファイルを圧縮し、サーバーにアップロードします

  • サーバーで .zip を解凍します。スクリプトを使用して、これを自動的に行います。必ずしも iPhone を介してサーバー上の解凍プロセスをリモート コントロールする必要はありません。
于 2012-08-03T07:03:43.583 に答える