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

Add support for more container paths #61

Closed Universal-Omega closed 1 year ago

Universal-Omega commented 1 year ago

I currently have to use the following in $wgExtensionFunctions, which is obviously not ideal:

global $wgFileBackends, $wgDBname, $wgAWSBucketName;
$wgFileBackends['s3']['containerPaths']["$wgDBname-avatars"] = "$wgAWSBucketName/$wgDBname/avatars";
$wgFileBackends['s3']['containerPaths']["$wgDBname-awards"] = "$wgAWSBucketName/$wgDBname/awards";
$wgFileBackends['s3']['containerPaths']["$wgDBname-dumps-backup"] = "$wgAWSBucketName/$wgDBname/dumps";
$wgFileBackends['s3']['containerPaths']["$wgDBname-local-transcoded"] = "$wgAWSBucketName/$wgDBname/transcoded";
$wgFileBackends['s3']['containerPaths']["$wgDBname-score-render"] = "$wgAWSBucketName/$wgDBname/score";
$wgFileBackends['s3']['containerPaths']["$wgDBname-timeline-render"] = "$wgAWSBucketName/$wgDBname/timeline";

If there is a way to do it, I apologize, if not if would if support could be added. Thanks!

edwardspec commented 1 year ago

I can move the list of zones into a configuration variable.

Currently it is hardcoded in https://github.com/edwardspec/mediawiki-aws-s3/blob/b4ab6bee32be8cd934926938b3b4cddfb4f55f2f/includes/AmazonS3Hooks.php#L74-L76 and in getS3RootDirInternal(), and also "-local-" is always added into container name in https://github.com/edwardspec/mediawiki-aws-s3/blob/b4ab6bee32be8cd934926938b3b4cddfb4f55f2f/includes/AmazonS3Hooks.php#L107

For now, if you want to avoid using $wgExtensionFunctions, you can instead use the old-style configuration (without $wgAWSBucketName, see tests/travis/OldStyleAWSSettings.php for an example), which allows to define $wgFileBackends['s3'] manually.

2023-05-30 22:17 GMT+03:00, CosmicAlpha @.***>:

I currently have to use the following in $wgExtensionFunctions, which is obviously not ideal:

global $wgFileBackends, $wgDBname, $wgAWSBucketName;
$wgFileBackends['s3']['containerPaths']["$wgDBname-avatars"] =
"$wgAWSBucketName/$wgDBname/avatars";
$wgFileBackends['s3']['containerPaths']["$wgDBname-awards"] =
"$wgAWSBucketName/$wgDBname/awards";
$wgFileBackends['s3']['containerPaths']["$wgDBname-dumps-backup"] =
"$wgAWSBucketName/$wgDBname/dumps";
$wgFileBackends['s3']['containerPaths']["$wgDBname-local-transcoded"] =
"$wgAWSBucketName/$wgDBname/transcoded";
$wgFileBackends['s3']['containerPaths']["$wgDBname-score-render"] =
"$wgAWSBucketName/$wgDBname/score";
$wgFileBackends['s3']['containerPaths']["$wgDBname-timeline-render"] =
"$wgAWSBucketName/$wgDBname/timeline";

If there is a way to do it, I apologize, if not if would if support could be added. Thanks!

-- Reply to this email directly or view it on GitHub: https://github.com/edwardspec/mediawiki-aws-s3/issues/61 You are receiving this because you are subscribed to this thread.

Message ID: @.***>

edwardspec commented 1 year ago

Would the following syntax be convenient and/or sufficient for the customization you need? (already implemented, not yet merged into master)

$wgAWSRepoZones['timeline'] = [
    'container' => 'timeline-render',
    'path' => '/timeline'
];
$wgAWSRepoZones['transcoded'] = [
    'container' => 'local-transcoded',
    'path' => '/transcoded',
    'isPublic' => true
];