diff --git a/src/applications/files/storage/PhabricatorFile.php b/src/applications/files/storage/PhabricatorFile.php --- a/src/applications/files/storage/PhabricatorFile.php +++ b/src/applications/files/storage/PhabricatorFile.php @@ -648,10 +648,17 @@ // just bail out. throw $status; } else { - // This is HTTP 2XX, so use the response body to save the - // file data. + // This is HTTP 2XX, so use the response body to save the file data. + // Provide a default name based on the URI, truncating it if the URI + // is exceptionally long. + + $default_name = basename($uri); + $default_name = id(new PhutilUTF8StringTruncator()) + ->setMaximumBytes(64) + ->truncateString($default_name); + $params = $params + array( - 'name' => basename($uri), + 'name' => $default_name, ); return self::newFromFileData($body, $params);