code: private File getTempFile(DigitalObject object, String pid)
              throws Exception {
          // Create file in temp space, use OID in path for uniqueness
          File directory = new File(tmpDir, object.getId());
          File target = new File(directory, pid);
          if (!target.exists()) {
              target.getParentFile().mkdirs();
              target.createNewFile();
          }
  
          // These can happily throw exceptions higher
          Payload payload = object.getPayload(pid);
          InputStream in = payload.open();
          FileOutputStream out = null;
  
          // But here, the payload must receive
          // a close before throwing the error
          try {
              out = new FileOutputStream(target);
              IOUtils.copyLarge(in, out);
  
          } catch (Exception ex) {
              close(out);
              target.delete();
              payload.close();
              throw ex;
          }
  
          // We close out here, because the catch statement needed to close
          // before it could delete... so it can't be in 'finally'
          close(out);
          payload.close();
  
          return target;
      }
docs: Stream the data out of storage to our temp directory.
  
  @param object Our digital object.
  @param pid The payload ID to retrieve.
  @return File The file creating in the temp directory
  @throws Exception on any errors