mrAceT / nextcloud-S3-local-S3-migration

Script for migrating Nextcloud primary storage from S3 to local to S3 storage
GNU General Public License v3.0
73 stars 12 forks source link

Added endpoint path style option #8

Closed stereu closed 1 year ago

mrAceT commented 1 year ago

Could this also work? (and be more compact)

if(!$CONFIG['objectstore']['arguments']['use_path_style']){
     $CONFIG['objectstore']['arguments']['use_path_style'] = false;
}
$s3 = new S3Client([
    'version' => 'latest',
    'endpoint' => 'https://'.$CONFIG['objectstore']['arguments']['hostname'].'/'.$bucket,
    'bucket_endpoint' => true,
    'use_path_style_endpoint' => $CONFIG['objectstore']['arguments']['use_path_style'],
    'region'  => $CONFIG['objectstore']['arguments']['region'],
    'credentials' => [
        'key' => $CONFIG['objectstore']['arguments']['key'],
        'secret' => $CONFIG['objectstore']['arguments']['secret'],
    ],
]);
mrAceT commented 1 year ago

AD: small question, is this required by your S3-proivider or is there an other reason you have set this option?

stereu commented 1 year ago

This won't work as in path-style the bucketname must be after the hostname and a slash. Without path-style the bucket name has to be a subdomain before the hostname. You can see it in the different endpoint definitions.

This option is required by some S3 providers in europe for example virtuozzo.

mrAceT commented 1 year ago

Ah! the endpoint is also different! Check!