Add the ability to create a macro from a url

Test Plan: Enter in a url and create a macro. :)

Reviewers: epriestley

Reviewed By: epriestley

CC: epriestley, aran, dctrwatson, Korvin

Differential Revision: https://secure.phabricator.com/D5039
This commit is contained in:
Matt Robenolt
2013-02-21 12:43:39 -08:00
committed by epriestley
parent 3c989590bf
commit e6281c3db0
5 changed files with 70 additions and 9 deletions

View File

@@ -333,7 +333,12 @@ final class PhabricatorFile extends PhabricatorFileDAO
}
public static function newFromFileDownload($uri, array $params) {
public static function newFromFileDownload($uri, array $params = array()) {
// Make sure we're allowed to make a request first
if (!PhabricatorEnv::getEnvConfig('security.allow-outbound-http')) {
throw new Exception("Outbound HTTP requests are disabled!");
}
$uri = new PhutilURI($uri);
$protocol = $uri->getProtocol();
@@ -352,6 +357,10 @@ final class PhabricatorFile extends PhabricatorFileDAO
->setTimeout($timeout)
->resolvex();
$params = $params + array(
'name' => basename($uri),
);
return self::newFromFileData($file_data, $params);
}