mirror of
https://github.com/nextcloud/server.git
synced 2026-05-19 08:25:56 -04:00
Merge pull request #56614 from nextcloud/backport/56565/stable29
Some checks failed
Integration sqlite / changes (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, --tags ~@large files_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, capabilities_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, collaboration_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, comments_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, dav_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, federation_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, filesdrop_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, ldap_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, openldap_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, openldap_numerical_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, remoteapi_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, setup_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, sharees_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, sharing_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, videoverification_features) (push) Has been cancelled
Integration sqlite / integration-sqlite-summary (push) Has been cancelled
Some checks failed
Integration sqlite / changes (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, --tags ~@large files_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, capabilities_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, collaboration_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, comments_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, dav_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, federation_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, filesdrop_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, ldap_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, openldap_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, openldap_numerical_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, remoteapi_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, setup_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, sharees_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, sharing_features) (push) Has been cancelled
Integration sqlite / integration-sqlite (8.2, stable29, videoverification_features) (push) Has been cancelled
Integration sqlite / integration-sqlite-summary (push) Has been cancelled
[stable29] feat: emit an event when an S3 bucket is created
This commit is contained in:
commit
268c361e87
4 changed files with 86 additions and 0 deletions
|
|
@ -396,6 +396,7 @@ return array(
|
|||
'OCP\\Files\\Notify\\IChange' => $baseDir . '/lib/public/Files/Notify/IChange.php',
|
||||
'OCP\\Files\\Notify\\INotifyHandler' => $baseDir . '/lib/public/Files/Notify/INotifyHandler.php',
|
||||
'OCP\\Files\\Notify\\IRenameChange' => $baseDir . '/lib/public/Files/Notify/IRenameChange.php',
|
||||
'OCP\\Files\\ObjectStore\\Events\\BucketCreatedEvent' => $baseDir . '/lib/public/Files/ObjectStore/Events/BucketCreatedEvent.php',
|
||||
'OCP\\Files\\ObjectStore\\IObjectStore' => $baseDir . '/lib/public/Files/ObjectStore/IObjectStore.php',
|
||||
'OCP\\Files\\ObjectStore\\IObjectStoreMultiPartUpload' => $baseDir . '/lib/public/Files/ObjectStore/IObjectStoreMultiPartUpload.php',
|
||||
'OCP\\Files\\ReservedWordException' => $baseDir . '/lib/public/Files/ReservedWordException.php',
|
||||
|
|
|
|||
|
|
@ -429,6 +429,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
|
|||
'OCP\\Files\\Notify\\IChange' => __DIR__ . '/../../..' . '/lib/public/Files/Notify/IChange.php',
|
||||
'OCP\\Files\\Notify\\INotifyHandler' => __DIR__ . '/../../..' . '/lib/public/Files/Notify/INotifyHandler.php',
|
||||
'OCP\\Files\\Notify\\IRenameChange' => __DIR__ . '/../../..' . '/lib/public/Files/Notify/IRenameChange.php',
|
||||
'OCP\\Files\\ObjectStore\\Events\\BucketCreatedEvent' => __DIR__ . '/../../..' . '/lib/public/Files/ObjectStore/Events/BucketCreatedEvent.php',
|
||||
'OCP\\Files\\ObjectStore\\IObjectStore' => __DIR__ . '/../../..' . '/lib/public/Files/ObjectStore/IObjectStore.php',
|
||||
'OCP\\Files\\ObjectStore\\IObjectStoreMultiPartUpload' => __DIR__ . '/../../..' . '/lib/public/Files/ObjectStore/IObjectStoreMultiPartUpload.php',
|
||||
'OCP\\Files\\ReservedWordException' => __DIR__ . '/../../..' . '/lib/public/Files/ReservedWordException.php',
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ use Aws\S3\Exception\S3Exception;
|
|||
use Aws\S3\S3Client;
|
||||
use GuzzleHttp\Promise;
|
||||
use GuzzleHttp\Promise\RejectedPromise;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\Files\ObjectStore\Events\BucketCreatedEvent;
|
||||
use OCP\Files\StorageNotAvailableException;
|
||||
use OCP\ICertificateManager;
|
||||
use OCP\Server;
|
||||
|
|
@ -164,6 +166,13 @@ trait S3ConnectionTrait {
|
|||
throw new StorageNotAvailableException("The bucket will not be created because the name is not dns compatible, please correct it: " . $this->bucket);
|
||||
}
|
||||
$this->connection->createBucket(['Bucket' => $this->bucket]);
|
||||
Server::get(IEventDispatcher::class)
|
||||
->dispatchTyped(new BucketCreatedEvent(
|
||||
$this->bucket,
|
||||
$options['endpoint'],
|
||||
$options['region'],
|
||||
$options['version']
|
||||
));
|
||||
$this->testTimeout();
|
||||
} catch (S3Exception $e) {
|
||||
$logger->debug('Invalid remote storage.', [
|
||||
|
|
|
|||
75
lib/public/Files/ObjectStore/Events/BucketCreatedEvent.php
Normal file
75
lib/public/Files/ObjectStore/Events/BucketCreatedEvent.php
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
namespace OCP\Files\ObjectStore\Events;
|
||||
|
||||
use OCP\EventDispatcher\Event;
|
||||
|
||||
/**
|
||||
* @since 29.0.16
|
||||
*/
|
||||
class BucketCreatedEvent extends Event {
|
||||
private string $bucket;
|
||||
private string $endpoint;
|
||||
private string $region;
|
||||
private string $version;
|
||||
|
||||
/**
|
||||
* @param string $bucket
|
||||
* @param string $endpoint
|
||||
* @param string $region
|
||||
* @param string $version
|
||||
*
|
||||
* @since 29.0.16
|
||||
*/
|
||||
public function __construct(
|
||||
string $bucket,
|
||||
string $endpoint,
|
||||
string $region,
|
||||
string $version = 'latest',
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->bucket = $bucket;
|
||||
$this->endpoint = $endpoint;
|
||||
$this->region = $region;
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @since 29.0.16
|
||||
*/
|
||||
public function getBucket(): string {
|
||||
return $this->bucket;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @since 29.0.16
|
||||
*/
|
||||
public function getEndpoint(): string {
|
||||
return $this->endpoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @since 29.0.16
|
||||
*/
|
||||
public function getRegion(): string {
|
||||
return $this->region;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @since 29.0.16
|
||||
*/
|
||||
public function getVersion(): string {
|
||||
return $this->version;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue