1

I want to download an epub file in to my app locally by passing the url of the file:

http://www.jedisaber.com/eBooks/books/sample.epub

Clicking this url should download an epub. How can I get it to download to my app?

I tried using NSData but it didn't work. I also tried copying the file to my document directory but it also didn't work. Can anybody tell me how can I do this in Objective-C?

Any help code would be appreciated!

Thanks for any help.

skaffman
  • 398,947
  • 96
  • 818
  • 769
B25Dec
  • 2,301
  • 5
  • 31
  • 54
  • Hi , Do you find a solution for the above problem.If Yes than please write to me in the following link.Thanks in Advance. http://stackoverflow.com/questions/16416640/how-to-download-epub-format-file-from-url-to-document-directory-in-iphone – Sumit Sharma May 07 '13 at 12:35

2 Answers2

2

EPUB is a ZIP format, you can use any Binary Stream Downloading method and save the file first as a binary file on iPhone.

acroCan
  • 21
  • 3
0

AS arcon Mentioned EPUB is a ZIP format, You have to Unzip the file to unzip the file & save the documents directory to ur machine: ZipArchive* za = [[ZipArchive alloc] init]; if( [za UnzipOpenFile:[[NSBundle mainBundle] pathForResource:@"Help" ofType:@"epub"]] ){

    NSString *strPath = [NSString stringWithFormat:@"%@/UnzippedEpub",[self applicationDocumentsDirectory]];

    //Delete all the previous files
    NSFileManager *filemanager = [[NSFileManager alloc] init];
    if ([filemanager fileExistsAtPath:strPath]) {
        NSError *error;
        [filemanager removeItemAtPath:strPath error:&error];
    }
    [filemanager release];
    filemanager = nil;

    //start unzip
    [za UnzipFileTo:strPath overWrite:YES];
    NSLog(@"path : %@",strPath);
}                   
[za release];
srinivas
  • 949
  • 1
  • 6
  • 6