Skip to content

Commit

Permalink
Introduce public storage class for extending
Browse files Browse the repository at this point in the history
When writing external storage it is complicated to reimplement IStorage
and many others. This PR provides public classes to be extended to
provider storage specific implementations.
  • Loading branch information
Vincent Petry committed Nov 25, 2016
1 parent c1b3702 commit c72c159
Show file tree
Hide file tree
Showing 11 changed files with 276 additions and 13 deletions.
2 changes: 1 addition & 1 deletion apps/files_external/lib/Lib/Storage/AmazonS3.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
use Aws\S3\Exception\S3Exception;
use Icewind\Streams\IteratorDirectory;

class AmazonS3 extends \OC\Files\Storage\Common {
class AmazonS3 extends \OCP\Files\Storage\StorageAdapter {

/**
* @var \Aws\S3\S3Client
Expand Down
2 changes: 1 addition & 1 deletion apps/files_external/lib/Lib/Storage/Dropbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

require_once __DIR__ . '/../../../3rdparty/Dropbox/autoload.php';

class Dropbox extends \OC\Files\Storage\Common {
class Dropbox extends \OCP\Files\Storage\StorageAdapter {

private $dropbox;
private $root;
Expand Down
2 changes: 1 addition & 1 deletion apps/files_external/lib/Lib/Storage/Google.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
\OC_App::getAppPath('files_external').'/3rdparty/google-api-php-client/src');
require_once 'Google/autoload.php';

class Google extends \OC\Files\Storage\Common {
class Google extends \OCP\Files\Storage\StorageAdapter {

private $client;
private $id;
Expand Down
2 changes: 1 addition & 1 deletion apps/files_external/lib/Lib/Storage/SFTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* Uses phpseclib's Net\SFTP class and the Net\SFTP\Stream stream wrapper to
* provide access to SFTP servers.
*/
class SFTP extends \OC\Files\Storage\Common {
class SFTP extends \OCP\Files\Storage\StorageAdapter {
private $host;
private $user;
private $root;
Expand Down
3 changes: 1 addition & 2 deletions apps/files_external/lib/Lib/Storage/SMB.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@
use Icewind\Streams\IteratorDirectory;
use OC\Cache\CappedMemoryCache;
use OC\Files\Filesystem;
use OC\Files\Storage\Common;
use OCP\Files\StorageNotAvailableException;
use OCP\Util;

class SMB extends Common {
class SMB extends \OCP\Files\Storage\StorageAdapter {
/**
* @var \Icewind\SMB\Server
*/
Expand Down
2 changes: 1 addition & 1 deletion apps/files_external/lib/Lib/Storage/StreamWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

namespace OCA\Files_External\Lib\Storage;

abstract class StreamWrapper extends \OC\Files\Storage\Common {
abstract class StreamWrapper extends \OCP\Files\Storage\StorageAdapter {

/**
* @param string $path
Expand Down
2 changes: 1 addition & 1 deletion apps/files_external/lib/Lib/Storage/Swift.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
use OpenCloud\ObjectStore\Resource\DataObject;
use OpenCloud\ObjectStore\Exception;

class Swift extends \OC\Files\Storage\Common {
class Swift extends \OCP\Files\Storage\StorageAdapter {

/**
* @var \OpenCloud\ObjectStore\Service
Expand Down
41 changes: 41 additions & 0 deletions lib/public/Files/Storage/FlysystemStorageAdapter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* @author Vincent Petry <pvince81@owncloud.com>
*
* @copyright Copyright (c) 2016, ownCloud GmbH.
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

namespace OCP\Files\Storage;

/**
* Public storage adapter to be extended to connect to
* flysystem adapters
*
* @since 9.2
*/
abstract class FlysystemStorageAdapter extends \OC\Files\Storage\Flysystem {

/**
* Get the identifier for the storage,
* the returned id should be the same for every storage object that is created with the same parameters
* and two storage objects with the same id should refer to two storages that display the same files.
*
* @return string storage id
* @since 9.2
*/
abstract public function getId();
}
Loading

0 comments on commit c72c159

Please sign in to comment.