AmazonS3.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Morris Jobke <hey@morrisjobke.de>
  6. * @author Robin Appelman <robin@icewind.nl>
  7. * @author Robin McCorkell <robin@mccorkell.me.uk>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. *
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. namespace OCA\Files_External\Lib\Backend;
  26. use OCA\Files_External\Lib\Auth\AmazonS3\AccessKey;
  27. use OCA\Files_External\Lib\Auth\AuthMechanism;
  28. use OCA\Files_External\Lib\DefinitionParameter;
  29. use OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
  30. use OCP\IL10N;
  31. class AmazonS3 extends Backend {
  32. use LegacyDependencyCheckPolyfill;
  33. public function __construct(IL10N $l, AccessKey $legacyAuth) {
  34. $this
  35. ->setIdentifier('amazons3')
  36. ->addIdentifierAlias('\OC\Files\Storage\AmazonS3') // legacy compat
  37. ->setStorageClass('\OCA\Files_External\Lib\Storage\AmazonS3')
  38. ->setText($l->t('Amazon S3'))
  39. ->addParameters([
  40. new DefinitionParameter('bucket', $l->t('Bucket')),
  41. (new DefinitionParameter('hostname', $l->t('Hostname')))
  42. ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
  43. (new DefinitionParameter('port', $l->t('Port')))
  44. ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
  45. (new DefinitionParameter('region', $l->t('Region')))
  46. ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
  47. (new DefinitionParameter('use_ssl', $l->t('Enable SSL')))
  48. ->setType(DefinitionParameter::VALUE_BOOLEAN),
  49. (new DefinitionParameter('use_path_style', $l->t('Enable Path Style')))
  50. ->setType(DefinitionParameter::VALUE_BOOLEAN),
  51. (new DefinitionParameter('legacy_auth', $l->t('Legacy (v2) authentication')))
  52. ->setType(DefinitionParameter::VALUE_BOOLEAN),
  53. ])
  54. ->addAuthScheme(AccessKey::SCHEME_AMAZONS3_ACCESSKEY)
  55. ->addAuthScheme(AuthMechanism::SCHEME_NULL)
  56. ->setLegacyAuthMechanism($legacyAuth)
  57. ;
  58. }
  59. }