edwardspec / mediawiki-aws-s3

Extension:AWS allows MediaWiki to use Amazon S3 (instead of the local directory) to store images.
https://www.mediawiki.org/wiki/Extension:AWS
GNU General Public License v2.0
42 stars 32 forks source link

Images Uploaded to S3 Not Displaying in Private Wiki #74

Closed mbarram closed 8 months ago

mbarram commented 8 months ago

Hello,

I am experiencing an issue with displaying images in my private MediaWiki instance, which is configured to use AWS S3 for image storage.

Images are successfully uploaded to the S3 bucket e.g. issue

but they are not correctly displayed in the wiki. The images appear to be missing or broken.

The source URL for images in the wiki is generated in the following format: src="/img_auth.php/logo.png?20231222135434". This seems to be incorrect or not properly linked to the S3 bucket where the images are stored.

I am seeking assistance to correctly link the S3 stored images with my private wiki so that they display properly. Any guidance or suggestions to resolve this issue would be greatly appreciated.

Thank you in advance for your help.

LocalSettings.php

$wgDBname = "@WIKI_DB_DATABASE@";
wfLoadExtension( 'AWS' );
$wgAWSCredentials = [
    'key' => '@AWS_ROBOT_KEY@',
    'secret' => '@AWS_ROBOT_SECRET@',
    'token' => false
];
$wgAWSRegion = '@AWS_REGION@';
$wgAWSBucketName = '@AWS_BUCKET_NAME@';
$wgDebugLogGroups['FileOperation'] = '/tmp/S3FileOperation.log';

Error log

2023-12-22 15:03:18 33769e35a55f wiki: S3FileBackend: doGetFileStat(): obtaining information about wiki/thumb/logo.png/640px-logo.png in S3 bucket_name
2023-12-22 15:03:18 33769e35a55f wiki: FileBackendStore::ingestFreshFileStats: File mwstore://AmazonS3/local-thumb/logo.png/640px-logo.png does not exist
edwardspec commented 8 months ago

Private images are only served via the wiki's /img_auth.php (in the same directory as index.php and api.php). They are not served directly from S3.

mbarram commented 8 months ago

"Thank you very much for the response. So, what should I do to make my images visible in the wiki? Should I allow public access to the images in S3?"

edwardspec commented 8 months ago

URLs like /img_auth.php/logo.png?20231222135434 are correct and should be working. Investigate why they aren't. This script (img_auth.php) is a part of MediaWiki core, and it not working has nothing to do with this extension.

mbarram commented 8 months ago

Thanks again for the reposponse.

2023-12-26 18:48:59 e4246cd0f86d wiki: S3FileBackend: found backend with S3 buckets: main-eb-app-assets/wiki, main-eb-app-assets/wik
i/thumb, main-eb-app-assets/wiki/deleted, main-eb-app-assets/wiki/temp. (private wiki, new S3 objects will be private)
2023-12-26 18:48:59 e4246cd0f86d wiki: S3FileBackend: doGetFileStat(): obtaining information about wiki/thumb/Aws-logo.png/2560px-Aws-logo.png in S3 bucket main-eb-
app-assets
2023-12-26 18:48:59 e4246cd0f86d wiki: FileBackendStore::ingestFreshFileStats: File mwstore://AmazonS3/local-thumb/Aws-logo.png/2560px-Aws-logo.png does not exist

I was investigating the issue and I believe there are problems with the thumbnails.

Currently, only the 'temp' folder is created in my bucket. Thumbnails are not visible because MediaWiki can't find the files. Here are some logs that illustrate the issue:

2023-12-26 18:54:02 e4246cd0f86d wiki: FileBackendStore::ingestFreshFileStats: File mwstore://AmazonS3/local-thumb/archive/20231226183505!Aws-logo.png/120px-Aws-logo.png does not exist
2023-12-26 18:54:02 e4246cd0f86d wiki: S3FileBackend: doGetFileStat(): obtaining information about wiki/thumb/Aws-logo.png/640px-Aws-logo.png in S3 bucket main-eb-app-assets
2023-12-26 18:54:02 e4246cd0f86d wiki: FileBackendStore::ingestFreshFileStats: File mwstore://AmazonS3/local-thumb/Aws-logo.png/640px-Aws-logo.png does not exist

Sorry for the inconvenience. Do you have any idea where the problem might be? Thank you very much.

edwardspec commented 8 months ago

File mwstore://AmazonS3/local-thumb/Aws-logo.png/640px-Aws-logo.png does not exist

This is not an error.

MediaWiki always checks "does thumbnail exist?" to determine if it needs to generate a new thumbnail. "Does not exist" is a completely normal outcome of this check (MediaWiki will make a new thumbnail).

Creating a thumbnail can fail for a number of reasons, such as missing original file (Aws-logo.png), not having ImageMagick, conversion process exceeding $wgMaxShellMemory, etc.