Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/controller/PhabricatorFileDataController.php
| Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | $file = id(new PhabricatorFileQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withPHIDs(array($this->phid)) | ->withPHIDs(array($this->phid)) | ||||
| ->executeOne(); | ->executeOne(); | ||||
| if (!$file) { | if (!$file) { | ||||
| return new Aphront404Response(); | return new Aphront404Response(); | ||||
| } | } | ||||
| if (!$file->validateSecretKey($this->key)) { | |||||
| return new Aphront403Response(); | |||||
| } | |||||
| if ($file->getIsPartial()) { | |||||
| // We may be on the CDN domain, so we need to use a fully-qualified URI | // We may be on the CDN domain, so we need to use a fully-qualified URI | ||||
| // here to make sure we end up back on the main domain. | // here to make sure we end up back on the main domain. | ||||
| $info_uri = PhabricatorEnv::getURI($file->getInfoURI()); | $info_uri = PhabricatorEnv::getURI($file->getInfoURI()); | ||||
| return $this->newDialog() | |||||
| if (!$file->validateSecretKey($this->key)) { | |||||
| $dialog = $this->newDialog() | |||||
| ->setTitle(pht('Invalid Authorization')) | |||||
| ->appendParagraph( | |||||
| pht( | |||||
| 'The link you followed to access this file is no longer '. | |||||
| 'valid. The visibility of the file may have changed after '. | |||||
| 'the link was generated.')) | |||||
| ->appendParagraph( | |||||
| pht( | |||||
| 'You can continue to the file detail page to get more '. | |||||
| 'information and attempt to access the file.')) | |||||
| ->addCancelButton($info_uri, pht('Continue')); | |||||
| return id(new AphrontDialogResponse()) | |||||
| ->setDialog($dialog) | |||||
| ->setHTTPResponseCode(404); | |||||
| } | |||||
| if ($file->getIsPartial()) { | |||||
| $dialog = $this->newDialog() | |||||
| ->setTitle(pht('Partial Upload')) | ->setTitle(pht('Partial Upload')) | ||||
| ->appendParagraph( | ->appendParagraph( | ||||
| pht( | pht( | ||||
| 'This file has only been partially uploaded. It must be '. | 'This file has only been partially uploaded. It must be '. | ||||
| 'uploaded completely before you can download it.')) | 'uploaded completely before you can download it.')) | ||||
| ->addCancelButton($info_uri); | ->appendParagraph( | ||||
| pht( | |||||
| 'You can continue to the file detail page to monitor the '. | |||||
| 'upload progress of the file.')) | |||||
| ->addCancelButton($info_uri, pht('Continue')); | |||||
| return id(new AphrontDialogResponse()) | |||||
| ->setDialog($dialog) | |||||
| ->setHTTPResponseCode(404); | |||||
| } | } | ||||
| $this->file = $file; | $this->file = $file; | ||||
| return null; | return null; | ||||
| } | } | ||||
| private function getFile() { | private function getFile() { | ||||
| if (!$this->file) { | if (!$this->file) { | ||||
| throw new PhutilInvalidStateException('loadFile'); | throw new PhutilInvalidStateException('loadFile'); | ||||
| } | } | ||||
| return $this->file; | return $this->file; | ||||
| } | } | ||||
| } | } | ||||