Open simonking76 opened 4 years ago
This issue seems to have been introduced in v8.7.0
Using a fresh install and the default schema.sql with s3 configured I checked out each version and retested.
It started working as expected in v8.6.2 - in the File Library an uploaded image appeared correctly and it uses the s3 path rather than /project-name/assets.
also when installing on a shared host, the file path is incorrect.
Used: http://<domain>/<project>/assets/…
Expected http://<domain>/public/uploads/<project>/…
I can see a path being built here /src/helpers/file.php
if (!function_exists('get_thumbnail_path')) {
/**
* Returns a relative url for the given file pointing to the thumbnailer
*
* @param array $thumbnail
*
* @return string
*/
function get_thumbnail_path($name, $thumbnail, $addBasePath = false)
{
$path = '';
$projectName = get_api_project_from_request();
$paramsString = '?key=' . $thumbnail['key'];
$path = $projectName . '/assets/' . $name . $paramsString;
if ($addBasePath === true) {
$basePath = get_base_path();
$path = $basePath . $path;
}
return $path;
}
}
However changing that has no impact.
It seems to take the path from the append_storage_information method, depending on the proxy_downloads setting. If your proxy_downloads is set to false, then changing line 139 like so fixes it:
$data['url'] = $data['full_url'] = $fileRootUrl . $config->get('storage.root') . '/' . $row['filename_disk'];
BTW, if it's set to true, then it seems to work.
I tried changing the line from
$data['url'] = $data['full_url'] = $fileRootUrl . '/' . $row['filename_disk']; to $data['url'] = $data['full_url'] = $fileRootUrl . $config->get('storage.root') . '/' . $row['filename_disk'];
in directus/src/helpers/file.php which was line 145 on v8.8.1
I still get the local relative path and I see the broken image graphic instead of the upload.
changing proxy_downloads = true didn't work, the file path didn't show at all.
• Version of Directus (must be the latest) v8.8.1
• Server, OS & Database Details Ubuntu 18, PHP7.2.24, MySQL 5.7.31
• Error Messages
{"error":{"code":null,"message":"Could not rewind stream","class":"RuntimeException","file":"\/var\/www\/html\/directus-v8-8-1\/directus\/vendor\/slim\/slim\/Slim\/Http\/Stream.php","line":367}}
• Steps to Reproduce
fresh install of latest directus v8.8.1
/src/schema.sql imported into database
configured /config/dev.php as environment (copying _example.php) to point to database.
installed: composer require league/flysystem-aws-s3-v3
configured config file with the S3 credentials as per: https://docs.directus.io/extensions/storage-adapters.html#using-aws-s3
Upload a file in the files section in Directus.
The file is successfully uploaded to S3, but Directus shows a broken image path in files section as its trying to load the image from /project-name/assets/
Same result when creating a collection with a file field, the file is uploaded to S3 bucket but in the file field the image is a broken path as trying to use /project-name/assets/filename.jpg
• Relevant Info, Screenshots, Schema & Logs
S3 configured in project config file:
'storage' => [ 'adapter' => 's3', // What storage adapter to use for files // Defaults to the local filesystem. Other natively supported // options include: Amazon S3, Aliyun OSS, Azure // You'll need to require the correct flysystem adapters through Composer // See https://docs.directus.io/extensions/storage-adapters.html#using-aws-s3
Can be repeated every time following the steps to reproduce.