Pass instance through file transform URIs
Summary: This makes thumbnail URIs work on instanced, CDN'd installs like Phacility cluster instances. Some of these transforms can proabably be removed, but the underlying code to generate the transform should be cleaned up too and we have some other tasks filed elsewhere about this anyway. Test Plan: CDN'd local install now loads thumbnails properly. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D11719
This commit is contained in:
@@ -84,7 +84,11 @@ final class PhabricatorFilesApplication extends PhabricatorApplication {
|
|||||||
'.*'
|
'.*'
|
||||||
=> 'PhabricatorFileDataController',
|
=> 'PhabricatorFileDataController',
|
||||||
'proxy/' => 'PhabricatorFileProxyController',
|
'proxy/' => 'PhabricatorFileProxyController',
|
||||||
'xform/(?P<transform>[^/]+)/(?P<phid>[^/]+)/(?P<key>[^/]+)/'
|
'xform/'.
|
||||||
|
'(?:@(?P<instance>[^/]+)/)?'.
|
||||||
|
'(?P<transform>[^/]+)/'.
|
||||||
|
'(?P<phid>[^/]+)/'.
|
||||||
|
'(?P<key>[^/]+)/'
|
||||||
=> 'PhabricatorFileTransformController',
|
=> 'PhabricatorFileTransformController',
|
||||||
'uploaddialog/' => 'PhabricatorFileUploadDialogController',
|
'uploaddialog/' => 'PhabricatorFileUploadDialogController',
|
||||||
'download/(?P<phid>[^/]+)/' => 'PhabricatorFileDialogController',
|
'download/(?P<phid>[^/]+)/' => 'PhabricatorFileDialogController',
|
||||||
|
|||||||
@@ -620,46 +620,52 @@ final class PhabricatorFile extends PhabricatorFileDAO
|
|||||||
return (string) $uri;
|
return (string) $uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getProfileThumbURI() {
|
private function getTransformedURI($transform) {
|
||||||
$path = '/file/xform/thumb-profile/'.$this->getPHID().'/'
|
$parts = array();
|
||||||
.$this->getSecretKey().'/';
|
$parts[] = 'file';
|
||||||
|
$parts[] = 'xform';
|
||||||
|
|
||||||
|
$instance = PhabricatorEnv::getEnvConfig('cluster.instance');
|
||||||
|
if (strlen($instance)) {
|
||||||
|
$parts[] = '@'.$instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
$parts[] = $transform;
|
||||||
|
$parts[] = $this->getPHID();
|
||||||
|
$parts[] = $this->getSecretKey();
|
||||||
|
|
||||||
|
$path = implode('/', $parts);
|
||||||
|
$path = $path.'/';
|
||||||
|
|
||||||
return PhabricatorEnv::getCDNURI($path);
|
return PhabricatorEnv::getCDNURI($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getProfileThumbURI() {
|
||||||
|
return $this->getTransformedURI('thumb-profile');
|
||||||
|
}
|
||||||
|
|
||||||
public function getThumb60x45URI() {
|
public function getThumb60x45URI() {
|
||||||
$path = '/file/xform/thumb-60x45/'.$this->getPHID().'/'
|
return $this->getTransformedURI('thumb-60x45');
|
||||||
.$this->getSecretKey().'/';
|
|
||||||
return PhabricatorEnv::getCDNURI($path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getThumb160x120URI() {
|
public function getThumb160x120URI() {
|
||||||
$path = '/file/xform/thumb-160x120/'.$this->getPHID().'/'
|
return $this->getTransformedURI('thumb-160x120');
|
||||||
.$this->getSecretKey().'/';
|
|
||||||
return PhabricatorEnv::getCDNURI($path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPreview100URI() {
|
public function getPreview100URI() {
|
||||||
$path = '/file/xform/preview-100/'.$this->getPHID().'/'
|
return $this->getTransformedURI('preview-100');
|
||||||
.$this->getSecretKey().'/';
|
|
||||||
return PhabricatorEnv::getCDNURI($path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPreview220URI() {
|
public function getPreview220URI() {
|
||||||
$path = '/file/xform/preview-220/'.$this->getPHID().'/'
|
return $this->getTransformedURI('preview-220');
|
||||||
.$this->getSecretKey().'/';
|
|
||||||
return PhabricatorEnv::getCDNURI($path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getThumb220x165URI() {
|
public function getThumb220x165URI() {
|
||||||
$path = '/file/xform/thumb-220x165/'.$this->getPHID().'/'
|
return $this->getTransfomredURI('thumb-220x165');
|
||||||
.$this->getSecretKey().'/';
|
|
||||||
return PhabricatorEnv::getCDNURI($path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getThumb280x210URI() {
|
public function getThumb280x210URI() {
|
||||||
$path = '/file/xform/thumb-280x210/'.$this->getPHID().'/'
|
return $this->getTransformedURI('thumb-280x210');
|
||||||
.$this->getSecretKey().'/';
|
|
||||||
return PhabricatorEnv::getCDNURI($path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isViewableInBrowser() {
|
public function isViewableInBrowser() {
|
||||||
|
|||||||
Reference in New Issue
Block a user