1

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

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

我的问题是我想从网络服务器上传/下载一个文件夹到本地 ,我首先压缩本地文件夹,然后从网络服务器上传它。

通过创建 Zip 上传/下载文件夹是否正确?

4

3 回答 3

1

-(void)updateFromInternet

{

进度视图.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 回答