1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 15:22:41 +01:00

Put file name in view URI, so downloading it with option-return creates a

usefully-named file

Summary:
If you Command-L + Option-Return to download stuff off, e.g., Paste,
you get "PHID-FILE-ad98abg9bsd9ashbs.txt" in your download folder. Put the file
name in the URI instead, so you get a reasonably named file.

Test Plan: Downloaded some files, got reasonable results.

Reviewers: btrahan, jungejason

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D1427
This commit is contained in:
epriestley 2012-01-16 16:20:18 -08:00
parent f94c05a5bb
commit 96c08a4f37
2 changed files with 6 additions and 3 deletions

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -228,15 +228,17 @@ class PhabricatorFile extends PhabricatorFileDAO {
"You must save a file before you can generate a view URI."); "You must save a file before you can generate a view URI.");
} }
$name = phutil_escape_uri($this->getName());
$alt = PhabricatorEnv::getEnvConfig('security.alternate-file-domain'); $alt = PhabricatorEnv::getEnvConfig('security.alternate-file-domain');
if ($alt) { if ($alt) {
$path = '/file/alt/'.$this->getSecretKey().'/'.$this->getPHID().'/'; $path = '/file/alt/'.$this->getSecretKey().'/'.$this->getPHID().'/'.$name;
$uri = new PhutilURI($alt); $uri = new PhutilURI($alt);
$uri->setPath($path); $uri->setPath($path);
return (string)$uri; return (string)$uri;
} else { } else {
return '/file/view/'.$this->getPHID().'/'; return '/file/view/'.$this->getPHID().'/'.$name;
} }
} }

View file

@ -16,6 +16,7 @@ phutil_require_module('phutil', 'error');
phutil_require_module('phutil', 'filesystem'); phutil_require_module('phutil', 'filesystem');
phutil_require_module('phutil', 'filesystem/tempfile'); phutil_require_module('phutil', 'filesystem/tempfile');
phutil_require_module('phutil', 'future/exec'); phutil_require_module('phutil', 'future/exec');
phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'parser/uri'); phutil_require_module('phutil', 'parser/uri');
phutil_require_module('phutil', 'symbols'); phutil_require_module('phutil', 'symbols');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');