AmazonS3.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCA\Files_External\Lib\Backend;
  8. use OCA\Files_External\Lib\Auth\AmazonS3\AccessKey;
  9. use OCA\Files_External\Lib\Auth\AuthMechanism;
  10. use OCA\Files_External\Lib\DefinitionParameter;
  11. use OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
  12. use OCP\IL10N;
  13. class AmazonS3 extends Backend {
  14. use LegacyDependencyCheckPolyfill;
  15. public function __construct(IL10N $l, AccessKey $legacyAuth) {
  16. $this
  17. ->setIdentifier('amazons3')
  18. ->addIdentifierAlias('\OC\Files\Storage\AmazonS3') // legacy compat
  19. ->setStorageClass('\OCA\Files_External\Lib\Storage\AmazonS3')
  20. ->setText($l->t('Amazon S3'))
  21. ->addParameters([
  22. new DefinitionParameter('bucket', $l->t('Bucket')),
  23. (new DefinitionParameter('hostname', $l->t('Hostname')))
  24. ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
  25. (new DefinitionParameter('port', $l->t('Port')))
  26. ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
  27. (new DefinitionParameter('region', $l->t('Region')))
  28. ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
  29. (new DefinitionParameter('storageClass', $l->t('Storage Class')))
  30. ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
  31. (new DefinitionParameter('use_ssl', $l->t('Enable SSL')))
  32. ->setType(DefinitionParameter::VALUE_BOOLEAN)
  33. ->setDefaultValue(true),
  34. (new DefinitionParameter('use_path_style', $l->t('Enable Path Style')))
  35. ->setType(DefinitionParameter::VALUE_BOOLEAN),
  36. (new DefinitionParameter('legacy_auth', $l->t('Legacy (v2) authentication')))
  37. ->setType(DefinitionParameter::VALUE_BOOLEAN),
  38. (new DefinitionParameter('useMultipartCopy', $l->t('Enable multipart copy')))
  39. ->setType(DefinitionParameter::VALUE_BOOLEAN)
  40. ->setDefaultValue(true),
  41. ])
  42. ->addAuthScheme(AccessKey::SCHEME_AMAZONS3_ACCESSKEY)
  43. ->addAuthScheme(AuthMechanism::SCHEME_NULL)
  44. ->setLegacyAuthMechanism($legacyAuth)
  45. ;
  46. }
  47. }