use Friendica\Core\Storage\Exception\ReferenceStorageException;
use Friendica\Core\Storage\Exception\StorageException;
use Friendica\Core\Storage\Type\SystemResource;
+use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Object\Image;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Images;
$filename = basename($image_url);
if (!empty($image_url)) {
- $ret = DI::httpClient()->get($image_url);
+ $ret = DI::httpClient()->get($image_url, HttpClientAccept::IMAGE);
+ Logger::debug('Got picture', ['Content-Type' => $ret->getHeader('Content-Type'), 'url' => $image_url]);
$img_str = $ret->getBody();
$type = $ret->getContentType();
} else {
}
$image_uri = substr($image_uri, strrpos($image_uri, '/') + 1);
$image_uri = substr($image_uri, 0, strpos($image_uri, '-'));
- if (!strlen($image_uri)) {
- return '';
- }
- return $image_uri;
+ return trim($image_uri);
+ }
+
+ /**
+ * Checks if the given URL is a local photo.
+ * Since it is meant for time critical occasions, the check is done without any database requests.
+ *
+ * @param string $url
+ * @return boolean
+ */
+ public static function isPhotoURI(string $url): bool
+ {
+ return !empty(self::ridFromURI($url));
}
/**
{
$filename = basename($image_url);
if (!empty($image_url)) {
- $ret = DI::httpClient()->get($image_url);
+ $ret = DI::httpClient()->get($image_url, HttpClientAccept::IMAGE);
+ Logger::debug('Got picture', ['Content-Type' => $ret->getHeader('Content-Type'), 'url' => $image_url]);
$img_str = $ret->getBody();
$type = $ret->getContentType();
} else {
}
/**
- *
- * @param int $uid User ID
- * @param array $files uploaded file array
+ * @param int $uid User ID
+ * @param array $files uploaded file array
+ * @param string $album
+ * @param string|null $allow_cid
+ * @param string|null $allow_gid
+ * @param string $deny_cid
+ * @param string $deny_gid
+ * @param string $desc
+ * @param string $resource_id
* @return array photo record
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function upload(int $uid, array $files, string $album = '', string $allow_cid = null, string $allow_gid = null, string $deny_cid = '', string $deny_gid = '', string $desc = '', string $resource_id = ''): array
{