diff --git a/src/applications/differential/controller/changesetview/DifferentialChangesetViewController.php b/src/applications/differential/controller/changesetview/DifferentialChangesetViewController.php index 3b16aa3c8f..75975104ee 100644 --- a/src/applications/differential/controller/changesetview/DifferentialChangesetViewController.php +++ b/src/applications/differential/controller/changesetview/DifferentialChangesetViewController.php @@ -48,13 +48,20 @@ class DifferentialChangesetViewController extends DifferentialController { $view = $request->getStr('view'); if ($view) { $changeset->attachHunks($changeset->loadHunks()); - switch ($view) { - case 'new': - return $this->buildRawFileResponse($changeset->makeNewFile()); - case 'old': - return $this->buildRawFileResponse($changeset->makeOldFile()); - default: - return new Aphront400Response(); + $type = $changeset->getFileType(); + if ($type === DifferentialChangeType::FILE_TEXT) { + switch ($view) { + case 'new': + return $this->buildRawFileResponse($changeset->makeNewFile()); + case 'old': + return $this->buildRawFileResponse($changeset->makeOldFile()); + default: + return new Aphront400Response(); + } + } else if ($type === DifferentialChangeType::FILE_IMAGE || + $type === DifferentialChangeType::FILE_BINARY) { + $phid = idx($changeset->getMetadata(), "$view:binary-phid"); + return id(new AphrontRedirectResponse())->setURI("/file/info/$phid/"); } } diff --git a/src/applications/differential/controller/changesetview/__init__.php b/src/applications/differential/controller/changesetview/__init__.php index f7457700a8..dd03e94eeb 100644 --- a/src/applications/differential/controller/changesetview/__init__.php +++ b/src/applications/differential/controller/changesetview/__init__.php @@ -12,6 +12,8 @@ phutil_require_module('phabricator', 'aphront/response/400'); phutil_require_module('phabricator', 'aphront/response/404'); phutil_require_module('phabricator', 'aphront/response/ajax'); phutil_require_module('phabricator', 'aphront/response/file'); +phutil_require_module('phabricator', 'aphront/response/redirect'); +phutil_require_module('phabricator', 'applications/differential/constants/changetype'); phutil_require_module('phabricator', 'applications/differential/controller/base'); phutil_require_module('phabricator', 'applications/differential/parser/changeset'); phutil_require_module('phabricator', 'applications/differential/storage/changeset');