title: ObjectiveC - Reading ePub File Gotten From Dropbox
body: <p>So I'm pretty lost with this one and really new to epub files. I've done a bit of searching but can't seem to put everything together in my head. </p>
  
  <p>My app uses DropBox's Chooser API to get a file from a user's DropBox folder. In this case, I want to open up a .epub file. So when the user chooses a file, the DropBox API gives me back an NSURL object to that file. For example:</p>
  
  <pre><code>https://dl.dropboxusercontent.com/1/view/e8bmxpkree6nc67/The%20Art%20of%20War.epub
  </code></pre>
  
  <p>And now, I've tried a couple different tools to try to read this file. Originally, I tried using <a href="https://github.com/ricobeck/KFEpubKit" rel="nofollow">KFEpubKit</a>. But when I called: </p>
  
  <pre><code>epubURL; // The url from DropBox (shown above)
  NSURL *documentsURL = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
  self.epubController = [[KFEpubController alloc] initWithEpubURL:epubURL andDestinationFolder:documentsURL];
  self.epubController.delegate = self;
  [self.epubController openAsynchronous:YES]
  </code></pre>
  
  <p>I would get back an error that the file couldn't be unzipped. The error reads as:</p>
  
  <pre><code>Epub Error: Error Domain=KFEpubKitErrorDomain Code=1 "Could not extract epub file." UserInfo=0x170275400 {NSLocalizedDescription=Could not extract epub file.}
  </code></pre>
  
  <p>I looked into the code and narrowed down the problem a little bit. The KFEpubKit uses the <a href="https://github.com/soffes/ssziparchive" rel="nofollow">SSZipArchive</a> utility to unzip files. And from this point on, I'm a bit stuck. The <code>[SSZipArchive unzipFileAtPath: toDestination:]</code> call seems to be failing when used with the <code>epubURL.path</code>. I'm not sure if this has something to do with the fact that my file is a .epub extension and not a .zip extension. Or maybe there's some stuff to do after getting the URL from DropBox and before giving it to the KFEpubKit tool? </p>
  
  <p>In the end, I'm expecting to have to display the text of the book with a UIWebView. But I'm just not sure how to handle this .epub file. What should I do with the file from Dropbox? Any help is much appreciated. </p>