2017-09-07 2 views
1

Ich habe einen gezippten Ordner mit AFNetworking-Bibliothek herunterladen, Datei wird heruntergeladen, aber wenn ich versuche, diesen Zip-Ordner zu öffnen, wird es nicht geöffnet. Auf Mac-Rechner wird es auch nicht mit Doppelklick und Archiv-Utility extrahiert.Datei entpacken mit SSZipArchive nicht extrahieren Zip-Datei

NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) { 
    NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil]; 
    return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]]; 
} completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) { 
    NSLog(@"File downloaded to: %@", filePath); 
    [SSZipArchive unzipFileAtPath:[filePath path] toDestination: [[filePath path] stringByDeletingLastPathComponent]]; 
}]; 
+0

Welche Art von Fehler wirft 'SSZipArchive' auf? – CodeChanger

+0

Set-Attribute für Verzeichnis fehlgeschlagen: 2017-09-07 10_06_53.zip/.storage. – psk

+0

Fehler Domain = NSCOAErrorDomain Code = 4 "Die Datei" .storage "existiert nicht." UserInfo = {NSFilePath = 2017-09-07 10_06_53.zip/.storage, NSUnderlyingError = 0x600000053ce0 {Fehlerdomäne = NSPOSIXErrorDomain Code = 2 "Keine solche Datei oder kein Verzeichnis"}} – psk

Antwort

0

versuchen diese

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"vikas.sqlite"]; 
    NSString *outputPath = [paths objectAtIndex:0]; 
    [SSZipArchive unzipFileAtPath:path toDestination:outputPath delegate:self]; 

Entpacken Datei auf Ausgabepfad sein wird.

0

Statt

[SSZipArchive unzipFileAtPath:[filePath path] toDestination: [[filePath path] stringByDeletingLastPathComponent]]; 

Verwendung:

[SSZipArchive unzipFileAtPath:zipPath toDestination:destinationPath overwrite:NO password:nil error:nil] 

die Datei

+1

[Bitte formatieren Sie Ihren Code] (https://stackoverflow.com/editing-help) – Dwhitz

+0

Nicht funktioniert mit diesem Code auch, der gleiche Fehler erscheint. – psk

0

NSArray * Pfade = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES) zu dekomprimieren; NSString * basePath = ([Anzahl der Pfade]> 0)? [Pfade ObjektAtIndex: 0]: Null;

Verwandte Themen