使用iphone在Web服务器上压缩/解压缩文件

时间:2012-08-03 06:15:52

标签: iphone zip webserver

  

是否可以使用我们的iphone在Web服务器上压缩/解压缩文件以使用该文件?

如果是,请指导我该怎么做?

我的问题是我想从网络服务器上传/下载文件夹到本地我是通过第一个zip本地文件夹来完成的,然后从上传它网络服务器..

通过创建Zip是上传/下载文件夹的正确方法吗?

3 个答案:

答案 0 :(得分:1)

- (无效)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/

答案 1 :(得分:1)

终于结束了。 使用RecursionFunction这将完成...不需要Zip / Unzip文件夹..

      - (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];
}
}

答案 2 :(得分:0)

下载   - 从服务器下载zip并解压缩。

上传   - 使用miniZip在设备上压缩文件并上传到服务器

  • 在服务器上解压缩.zip。使用脚本自动执行此操作。不一定要通过iPhone远程控制服务器上的解压缩过程。