Skip to content

Commit

Permalink
The start of gzipped edits: make downloads work.
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfman2000 committed Apr 14, 2010
1 parent bed61e7 commit f812f59
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions apps/frontend/modules/edits/actions/actions.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,19 @@ public function executeDownload(sfWebRequest $request)
}
$id = sprintf("%06d", $id);
$name = sprintf("edit_%s.edit", $id);
$path = sprintf("%s/data/user_edits/%s", sfConfig::get('sf_root_dir'), $name);
$file = file_get_contents($path);

$gz = $name . '.gz';
$path = sprintf("%s/data/user_edits/%s", sfConfig::get('sf_root_dir'), $gz);
$file = gzopen($path, 'r');
$data = fread($file, sfConfig::get('app_max_edit_file_size'));
gzclose($file);

$response = $this->getResponse();
$response->clearHttpHeaders();
$response->setHttpHeader('Content-Disposition', 'attachment; filename='.$name);
$response->setHttpHeader('Content-Length', strlen($file));
$response->setHttpHeader('Content-Length', strlen($data));
$response->setHttpHeader('Content-Type', 'application/edit');
$response->sendHttpHeaders();
$response->setContent($file);
$response->setContent($data);

return sfView::NONE;
}
Expand Down

0 comments on commit f812f59

Please sign in to comment.