# media-cloud-sync/1.2.12/includes/base/service.php

Media Cloud Sync, version 1.2.12. 851 lines.

- Page: https://pluginprobe.com/plugins/media-cloud-sync/1.2.12/code/includes/base/service.php
- Raw: https://pluginprobe.com/plugins/media-cloud-sync/1.2.12/raw/includes/base/service.php
- Modified: 2025-08-06T10:37:34+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/media-cloud-sync/1.2.12/code/includes/base/service.php#L10-L20`.

```php
<?php
namespace Dudlewebs\WPMCS;

defined('ABSPATH') || exit;

class Service {
    private static $instance = null;
    private $assets_url;
    private $version;
    private $token;
    private $service = false;

    protected $settings;


    /**
     * Admin constructor.
     * @since 1.0.0
     */
    public function __construct() {
        $this->assets_url = WPMCS_ASSETS_URL;
        $this->version    = WPMCS_VERSION;
        $this->token      = WPMCS_TOKEN;

        $this->settings = Utils::get_settings();

        $current_service = Utils::get_service();
        switch ($current_service) {
            case 's3':
                $this->service = new S3;
                break;
            case 'gcloud':
                $this->service = new GCloud;
                break;
            case 'docean':
                $this->service = new DOcean;
                break;
            case 's3compatible':
                $this->service = new S3Compatible;
                break;
            default:$this->service = false;
        }
    }

    /**
     * Verify Service Credentials
     * @since 1.0.0
     */
    public function verifyCredentials($data) {
        $result = [
            'success' => false,
            'message' => esc_html__('Something went wrong', 'media-cloud-sync')
        ];
        
        $service = isset($data['service'])? $data['service'] : false;

        if($service == false) {
            $result = [
                'success' => false,
                'message' => esc_html__('No service selected', 'media-cloud-sync')
            ];
            return $result;
        }

        switch($service){
            case 's3':
                $config     = isset($data['config']) ? $data['config'] : [];
                $access_key = isset($config['access_key']) ? $config['access_key'] : false;
                $secret_key = isset($config['secret_key']) ? $config['secret_key'] : false;
                $region     = isset($config['region']) ? $config['region'] : false;

                if($access_key==false || $secret_key==false || $region==false) {
                    $result = [
                        'success' => false,
                        'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                    ];
                    return $result;
                }

                $currentService = new S3;
                return $currentService->verifyCredentials($access_key, $secret_key, $region);
                break;
            case 'gcloud':
                $config         = isset($data['config']) ? $data['config'] : [];
                $config_json    = isset($config['config_json']) ? $config['config_json'] : '';

                if(!(isset($config_json) && !empty($config_json))) {
                    $result = [
                        'success' => false,
                        'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                    ];
                    return $result;
                }
                
                if(!Utils::is_json($config_json)) {
                    $result = [
                        'success' => false,
                        'message' => esc_html__('Invalid JSON. Please try again', 'media-cloud-sync')
                    ];
                    return $result;
                }

                $currentService = new GCloud;
                return $currentService->verifyCredentials($config_json);
                break;
            case 'docean':
                $config     = isset($data['config']) ? $data['config'] : [];
                $access_key = isset($config['access_key']) ? $config['access_key'] : false;
                $secret_key = isset($config['secret_key']) ? $config['secret_key'] : false;
                $region     = isset($config['region']) ? $config['region'] : false;

                if($access_key==false || $secret_key==false || $region==false) {
                    $result = [
                        'success' => false,
                        'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                    ];
                    return $result;
                }

                $currentService = new DOcean;
                return $currentService->verifyCredentials($access_key, $secret_key, $region);
                break;
            case 's3compatible':
                $config     = isset($data['config']) ? $data['config'] : [];
                $access_key = isset($config['access_key']) ? $config['access_key'] : false;
                $secret_key = isset($config['secret_key']) ? $config['secret_key'] : false;
                $region     = isset($config['region']) ? $config['region'] : false;
                $endpoint   = isset($config['endpoint']) ? $config['endpoint'] : false;

                if($access_key==false || $secret_key==false || $endpoint==false) {
                    $result = [
                        'success' => false,
                        'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                    ];
                    return $result;
                }

                $currentService = new S3Compatible;
                return $currentService->verifyCredentials($endpoint, $access_key, $secret_key, $region);
                break;
            default: 
                $result = [
                    'success' => false,
                    'message' => esc_html__('Invalid service', 'media-cloud-sync')
                ];
        }

        return $result;
    }

    /**
     * Verify Bucket Exist
     * @since 1.0.0
     */
    public function verifyBucketExist($data) {
        $result = [
            'success' => false,
            'message' => esc_html__('Something went wrong', 'media-cloud-sync')
        ];
        
        $service = isset($data['service'])? $data['service'] : false;

        if($service == false) {
            $result = [
                'success' => false,
                'message' => esc_html__('No service selected', 'media-cloud-sync')
            ];
            return $result;
        }

        switch($service){
            case 's3':
                $result = [
                    'success' => false,
                    'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                ];
                $config                 = isset($data['config']) ? $data['config'] : [];
                $bucketData             = isset($data['bucketData']) ? $data['bucketData'] : [];
                $bucketConfig           = isset($bucketData['config']) ? $bucketData['config'] : [];
                $bucket                 = isset($bucketConfig['bucket_name']) ? $bucketConfig['bucket_name'] : false;
                $transfer_acceleration  = isset($bucketConfig['transfer_acceleration']) ? $bucketConfig['transfer_acceleration'] : false;
                $access_key             = isset($config['access_key']) ? $config['access_key'] : false;
                $secret_key             = isset($config['secret_key']) ? $config['secret_key'] : false;
                $region                 = isset($config['region']) ? $config['region'] : false;

                if( $access_key==false || $secret_key==false || $region==false || $bucket==false ) return $result;
                
                $currentService = new S3;


                return $currentService->verifyBucketExist($access_key, $secret_key, $region, $bucket, $transfer_acceleration);
                  
            case 'gcloud':
                $result = [
                    'success' => false,
                    'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                ];
                $config                 = isset($data['config']) ? $data['config'] : [];
                $config_json            = isset($config['config_json']) ? $config['config_json'] : '';

                $bucketData             = isset($data['bucketData']) ? $data['bucketData'] : [];
                $bucketConfig           = isset($bucketData['config']) ? $bucketData['config'] : [];
                $bucket                 = isset($bucketConfig['bucket_name']) ? $bucketConfig['bucket_name'] : false;

                if( !(isset($config_json) && !empty($config_json) && $bucket!=false ) ) return $result;

                if(!Utils::is_json($config_json)) {
                    $result = [
                        'success' => false,
                        'message' => esc_html__('Invalid config file', 'media-cloud-sync')
                    ];
                    return $result;
                };
                
                $currentService = new GCloud;
                return $currentService->verifyBucketExist($config_json, $bucket);
                break;
            case 'docean':
                $result = [
                    'success' => false,
                    'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                ];
                $config                 = isset($data['config']) ? $data['config'] : [];
                $bucketData             = isset($data['bucketData']) ? $data['bucketData'] : [];
                $bucketConfig           = isset($bucketData['config']) ? $bucketData['config'] : [];
                $bucket                 = isset($bucketConfig['bucket_name']) ? $bucketConfig['bucket_name'] : false;
                $access_key             = isset($config['access_key']) ? $config['access_key'] : false;
                $secret_key             = isset($config['secret_key']) ? $config['secret_key'] : false;
                $region                 = isset($config['region']) ? $config['region'] : false;

                if( $access_key==false || $secret_key==false || $region==false || $bucket==false ) return $result;
                
                $currentService = new DOcean;


                return $currentService->verifyBucketExist($access_key, $secret_key, $region, $bucket);
                break;
            case 's3compatible':
                $result = [
                    'success' => false,
                    'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                ];
                $config                 = isset($data['config']) ? $data['config'] : [];
                $bucketData             = isset($data['bucketData']) ? $data['bucketData'] : [];
                $bucketConfig           = isset($bucketData['config']) ? $bucketData['config'] : [];
                $bucket                 = isset($bucketConfig['bucket_name']) ? $bucketConfig['bucket_name'] : false;
                $access_key             = isset($config['access_key']) ? $config['access_key'] : false;
                $secret_key             = isset($config['secret_key']) ? $config['secret_key'] : false;
                $region                 = isset($config['region']) ? $config['region'] : false;
                $endpoint               = isset($config['endpoint']) ? $config['endpoint'] : false;

                if( $access_key==false || $secret_key==false || $bucket==false || $endpoint==false ) return $result;
                
                $currentService = new S3Compatible;

                return $currentService->verifyBucketExist($endpoint, $access_key, $secret_key, $bucket, $region);
                break;
            default: 
                $result = [
                    'success' => false,
                    'message' => esc_html__('Invalid service', 'media-cloud-sync')
                ];
        }

        return $result;
    }

    /**
     * Verify Bucket Credentials
     * @since 1.0.0
     */
    public function createBucket($data) {
        $result = [
            'success' => false,
            'message' => esc_html__('Something went wrong', 'media-cloud-sync')
        ];
        
        $service = isset($data['service'])? $data['service'] : false;

        if($service == false) {
            $result = [
                'success' => false,
                'message' => esc_html__('No service selected', 'media-cloud-sync')
            ];
            return $result;
        }

        switch($service){
            case 's3':
                $result = [
                    'success' => false,
                    'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                ];
                $config                 = isset($data['config']) ? $data['config'] : [];
                $bucketData             = isset($data['bucketData']) ? $data['bucketData'] : [];
                $bucketAddNewConfig     = isset($bucketData['addNewConfig']) ? $bucketData['addNewConfig'] : [];
                $bucket                 = isset($bucketAddNewConfig['bucket_name']) ? $bucketAddNewConfig['bucket_name'] : false;
                $transfer_acceleration  = isset($bucketAddNewConfig['transfer_acceleration']) ? $bucketAddNewConfig['transfer_acceleration'] : false;
                $access_key             = isset($config['access_key']) ? $config['access_key'] : false;
                $secret_key             = isset($config['secret_key']) ? $config['secret_key'] : false;
                $region                 = isset($config['region']) ? $config['region'] : false;

                if( $access_key==false || $secret_key==false || $region==false || $bucket==false ) return $result;
                
                $currentService = new S3;
                return $currentService->createBucket($access_key, $secret_key, $region, $bucket, $transfer_acceleration);
            case 'gcloud':
                $result = [
                    'success' => false,
                    'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                ];
                $config                 = isset($data['config']) ? $data['config'] : [];
                $config_json            = isset($config['config_json']) ? $config['config_json'] : '';

                $bucketConfig           = isset($data['bucketData']) ? $data['bucketData'] : [];
                $bucketAddNewConfig     = isset($bucketConfig['addNewConfig']) ? $bucketConfig['addNewConfig'] : [];
                $bucket                 = isset($bucketAddNewConfig['bucket_name']) ? $bucketAddNewConfig['bucket_name'] : false;
                $region                 = isset($bucketAddNewConfig['region']) ? $bucketAddNewConfig['region'] : false;

                if( !(isset($config_json) && !empty($config_json) &&$region!=false && $bucket!=false ) ) return $result;
                
                if(!Utils::is_json($config_json)) {
                    $result = [
                        'success' => false,
                        'message' => esc_html__('Invalid JSON', 'media-cloud-sync')
                    ];
                    return $result;
                };
                
                $currentService = new GCloud;
                return $currentService->createBucket($config_json, $region, $bucket);
                break;
            case 'docean':
                $result = [
                    'success' => false,
                    'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                ];
                
                $config                 = isset($data['config']) ? $data['config'] : [];
                $access_key             = isset($config['access_key']) ? $config['access_key'] : false;
                $secret_key             = isset($config['secret_key']) ? $config['secret_key'] : false;
                $region                 = isset($config['region']) ? $config['region'] : false;
                $bucketData             = isset($data['bucketData']) ? $data['bucketData'] : [];
                $bucketConfig           = isset($bucketData['addNewConfig']) ? $bucketData['addNewConfig'] : [];
                $bucket                 = isset($bucketConfig['bucket_name']) ? $bucketConfig['bucket_name'] : false;

                if( $access_key==false || $secret_key==false || $region==false || $bucket==false ) return $result;

                $currentService = new DOcean;
                return $currentService->createBucket($access_key, $secret_key, $region, $bucket);
                break;
            case 's3compatible':
                $result = [
                    'success' => false,
                    'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                ];
                
                $config                 = isset($data['config']) ? $data['config'] : [];
                $access_key             = isset($config['access_key']) ? $config['access_key'] : false;
                $secret_key             = isset($config['secret_key']) ? $config['secret_key'] : false;
                $region                 = isset($config['region']) ? $config['region'] : false;
                $endpoint               = isset($config['endpoint']) ? $config['endpoint'] : false;

                $bucketData             = isset($data['bucketData']) ? $data['bucketData'] : [];
                $bucketConfig           = isset($bucketData['addNewConfig']) ? $bucketData['addNewConfig'] : [];
                $bucket                 = isset($bucketConfig['bucket_name']) ? $bucketConfig['bucket_name'] : false;

                if( $access_key==false || $secret_key==false || $bucket==false || $endpoint==false ) return $result;

                $currentService = new S3Compatible;
                return $currentService->createBucket($endpoint, $access_key, $secret_key, $bucket, $region);
                break;
            default: 
                $result = [
                    'success' => false,
                    'message' => esc_html__('Invalid service', 'media-cloud-sync')
                ];
        }

        return $result;
    }

    /**
     * Verify Object write permission
     * @since 1.0.0
     */
    public function verifyObjectWritePermission($data) {
        $result = [
            'success' => false,
            'message' => esc_html__('Something went wrong', 'media-cloud-sync')
        ];
        
        $service = isset($data['service'])? $data['service'] : false;

        if($service == false) {
            $result = [
                'success' => false,
                'message' => esc_html__('No service selected', 'media-cloud-sync')
            ];
            return $result;
        }

        switch($service){
            case 's3':
                $result = [
                    'success' => false,
                    'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                ];
                $config                 = isset($data['config']) ? $data['config'] : [];
                $bucketData             = isset($data['bucketData']) ? $data['bucketData'] : [];
                if(isset($bucketData['addNew']) && $bucketData['addNew']) {
                    $bucketConfig           = isset($bucketData['addNewConfig']) ? $bucketData['addNewConfig'] : [];
                } else {
                    $bucketConfig           = isset($bucketData['config']) ? $bucketData['config'] : [];
                }
                $bucket                 = isset($bucketConfig['bucket_name']) ? $bucketConfig['bucket_name'] : false;
                $transfer_acceleration  = isset($bucketConfig['transfer_acceleration']) ? $bucketConfig['transfer_acceleration'] : false;
                $access_key             = isset($config['access_key']) ? $config['access_key'] : false;
                $secret_key             = isset($config['secret_key']) ? $config['secret_key'] : false;
                $region                 = isset($config['region']) ? $config['region'] : false;

                if( $access_key==false || $secret_key==false || $region==false || $bucket==false ) return $result;
                
                $currentService = new S3;
                return $currentService->verifyObjectWritePermission($access_key, $secret_key, $region, $bucket, $transfer_acceleration);
                  
            case 'gcloud':
                $result = [
                    'success' => false,
                    'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                ];
                $config                 = isset($data['config']) ? $data['config'] : [];
                $config_json            = isset($config['config_json']) ? $config['config_json'] : '';

                $bucketData             = isset($data['bucketData']) ? $data['bucketData'] : [];
                if(isset($bucketData['addNew']) && $bucketData['addNew']) {
                    $bucketConfig       = isset($bucketData['addNewConfig']) ? $bucketData['addNewConfig'] : [];
                } else {
                    $bucketConfig       = isset($bucketData['config']) ? $bucketData['config'] : [];
                }
                $bucket                 = isset($bucketConfig['bucket_name']) ? $bucketConfig['bucket_name'] : false;

                if( !(isset($config_json) && !empty($config_json) &&  $bucket!=false ) ) return $result;

                if(!Utils::is_json($config_json)) {
                    $result = [
                        'success' => false,
                        'message' => esc_html__('Invalid config json', 'media-cloud-sync') 
                    ];
                    return $result;
                }
                
                $currentService = new GCloud;
                return $currentService->verifyObjectWritePermission($config_json, $bucket);
                break;
            case 'docean':
                $result = [
                    'success' => false,
                    'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                ];
                $config                 = isset($data['config']) ? $data['config'] : [];
                $bucketData             = isset($data['bucketData']) ? $data['bucketData'] : [];
                if(isset($bucketData['addNew']) && $bucketData['addNew']) {
                    $bucketConfig           = isset($bucketData['addNewConfig']) ? $bucketData['addNewConfig'] : [];
                } else {
                    $bucketConfig           = isset($bucketData['config']) ? $bucketData['config'] : [];
                }
                $bucket                 = isset($bucketConfig['bucket_name']) ? $bucketConfig['bucket_name'] : false;
                $transfer_acceleration  = isset($bucketConfig['transfer_acceleration']) ? $bucketConfig['transfer_acceleration'] : false;
                $access_key             = isset($config['access_key']) ? $config['access_key'] : false;
                $secret_key             = isset($config['secret_key']) ? $config['secret_key'] : false;
                $region                 = isset($config['region']) ? $config['region'] : false;

                if( $access_key==false || $secret_key==false || $region==false || $bucket==false ) return $result;

                $currentService = new DOcean;
                return $currentService->verifyObjectWritePermission($access_key, $secret_key, $region, $bucket);
                break;
            case 's3compatible':
                $result = [
                    'success' => false,
                    'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                ];
                $config                 = isset($data['config']) ? $data['config'] : [];
                $bucketData             = isset($data['bucketData']) ? $data['bucketData'] : [];
                if(isset($bucketData['addNew']) && $bucketData['addNew']) {
                    $bucketConfig           = isset($bucketData['addNewConfig']) ? $bucketData['addNewConfig'] : [];
                } else {
                    $bucketConfig           = isset($bucketData['config']) ? $bucketData['config'] : [];
                }
                $bucket                 = isset($bucketConfig['bucket_name']) ? $bucketConfig['bucket_name'] : false;
                $transfer_acceleration  = isset($bucketConfig['transfer_acceleration']) ? $bucketConfig['transfer_acceleration'] : false;
                $access_key             = isset($config['access_key']) ? $config['access_key'] : false;
                $secret_key             = isset($config['secret_key']) ? $config['secret_key'] : false;
                $region                 = isset($config['region']) ? $config['region'] : false;
                $endpoint               = isset($config['endpoint']) ? $config['endpoint'] : false;

                if( $access_key==false || $secret_key==false || $endpoint==false || $bucket==false ) return $result;
                $currentService = new S3Compatible;
                return $currentService->verifyObjectWritePermission($endpoint, $access_key, $secret_key, $bucket, $region);
                break;
            default: 
                break;
        }

        return false;
    }


    /**
     * Verify Object delete permission
     * @since 1.0.0
     */
    public function verifyObjectDeletePermission($data) {
        $result = [
            'success' => false,
            'message' => esc_html__('Something went wrong', 'media-cloud-sync')
        ];
        
        $service = isset($data['service'])? $data['service'] : false;

        if($service == false) {
            $result = [
                'success' => false,
                'message' => esc_html__('No service selected', 'media-cloud-sync')
            ];
            return $result;
        }

        switch($service){
            case 's3':
                $result = [
                    'success' => false,
                    'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                ];
                $config                 = isset($data['config']) ? $data['config'] : [];
                $bucketData             = isset($data['bucketData']) ? $data['bucketData'] : [];
                if(isset($bucketData['addNew']) && $bucketData['addNew']) {
                    $bucketConfig           = isset($bucketData['addNewConfig']) ? $bucketData['addNewConfig'] : [];
                } else {
                    $bucketConfig           = isset($bucketData['config']) ? $bucketData['config'] : [];
                }
                $bucket                 = isset($bucketConfig['bucket_name']) ? $bucketConfig['bucket_name'] : false;
                $transfer_acceleration  = isset($bucketConfig['transfer_acceleration']) ? $bucketConfig['transfer_acceleration'] : false;
                $access_key             = isset($config['access_key']) ? $config['access_key'] : false;
                $secret_key             = isset($config['secret_key']) ? $config['secret_key'] : false;
                $region                 = isset($config['region']) ? $config['region'] : false;

                if( $access_key==false || $secret_key==false || $region==false || $bucket==false ) return $result;
                
                $currentService = new S3;
                return $currentService->verifyObjectDeletePermission($access_key, $secret_key, $region, $bucket, $transfer_acceleration);
                  
            case 'gcloud':
                $result = [
                    'success' => false,
                    'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                ];
                $config                 = isset($data['config']) ? $data['config'] : [];
                $config_json            = isset($config['config_json']) ? $config['config_json'] : '';
                $bucketData             = isset($data['bucketData']) ? $data['bucketData'] : [];
                if(isset($bucketData['addNew']) && $bucketData['addNew']) {
                    $bucketConfig           = isset($bucketData['addNewConfig']) ? $bucketData['addNewConfig'] : [];
                } else {
                    $bucketConfig           = isset($bucketData['config']) ? $bucketData['config'] : [];
                }
                $bucket                 = isset($bucketConfig['bucket_name']) ? $bucketConfig['bucket_name'] : false;

                if( !(isset($config_json) && !empty($config_json) && $bucket!=false) ) return $result;

                if(!Utils::is_json($config_json)) {
                    $result = [
                        'success' => false,
                        'message' => esc_html__('Invalid config json', 'media-cloud-sync')
                    ];
                    return $result;
                }

                $currentService = new GCloud;
                return $currentService->verifyObjectDeletePermission($config_json, $bucket);
                break;
            case 'docean':
                $result = [
                    'success' => false,
                    'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                ];
                $config                 = isset($data['config']) ? $data['config'] : [];
                $bucketData             = isset($data['bucketData']) ? $data['bucketData'] : [];
                if(isset($bucketData['addNew']) && $bucketData['addNew']) {
                    $bucketConfig           = isset($bucketData['addNewConfig']) ? $bucketData['addNewConfig'] : [];
                } else {
                    $bucketConfig           = isset($bucketData['config']) ? $bucketData['config'] : [];
                }
                $bucket                 = isset($bucketConfig['bucket_name']) ? $bucketConfig['bucket_name'] : false;
                $access_key             = isset($config['access_key']) ? $config['access_key'] : false;
                $secret_key             = isset($config['secret_key']) ? $config['secret_key'] : false;
                $region                 = isset($config['region']) ? $config['region'] : false;

                if( $access_key==false || $secret_key==false || $region==false || $bucket==false ) return $result;

                $currentService = new DOcean;
                return $currentService->verifyObjectDeletePermission($access_key, $secret_key, $region, $bucket);
                break;
            case 's3compatible':
                $result = [
                    'success' => false,
                    'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                ];
                $config                 = isset($data['config']) ? $data['config'] : [];
                $bucketData             = isset($data['bucketData']) ? $data['bucketData'] : [];
                if(isset($bucketData['addNew']) && $bucketData['addNew']) {
                    $bucketConfig           = isset($bucketData['addNewConfig']) ? $bucketData['addNewConfig'] : [];
                } else {
                    $bucketConfig           = isset($bucketData['config']) ? $bucketData['config'] : [];
                }
                $bucket                 = isset($bucketConfig['bucket_name']) ? $bucketConfig['bucket_name'] : false;
                $access_key             = isset($config['access_key']) ? $config['access_key'] : false;
                $secret_key             = isset($config['secret_key']) ? $config['secret_key'] : false;
                $region                 = isset($config['region']) ? $config['region'] : false;
                $endpoint               = isset($config['endpoint']) ? $config['endpoint'] : false;

                if( $access_key==false || $secret_key==false || $endpoint==false || $bucket==false ) return $result;

                $currentService = new S3Compatible;
                return $currentService->verifyObjectDeletePermission($endpoint, $access_key, $secret_key, $bucket, $region);
                break;
            default: 
                break;
        }

        return false;
    }


    /**
     * Verify Object read permission
     * @since 1.0.0
     */
    public function verifyObjectReadPermission($data) {
        return $this->service->verifyObjectReadPermission($data);
    }

    /**
     * Get Bucket Security Settings
     */
    public function getBucketSecuritySettings($data) {
        $result = [
            'success' => false,
            'message' => esc_html__('Something went wrong', 'media-cloud-sync')
        ];
        
        $service = isset($data['service'])? $data['service'] : false;

        if($service == false) {
            $result = [
                'success' => false,
                'message' => esc_html__('No service selected', 'media-cloud-sync')
            ];
            return $result;
        }

        switch($service){
            case 's3':
                $result = [
                    'success' => false,
                    'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                ];   
                $config                 = isset($data['config']) ? $data['config'] : [];
                $bucketData             = isset($data['bucketData']) ? $data['bucketData'] : [];
                if(isset($bucketData['addNew']) && $bucketData['addNew']) {
                    $bucketConfig           = isset($bucketData['addNewConfig']) ? $bucketData['addNewConfig'] : [];
                } else {
                    $bucketConfig           = isset($bucketData['config']) ? $bucketData['config'] : [];
                }
                $bucket                 = isset($bucketConfig['bucket_name']) ? $bucketConfig['bucket_name'] : false;
                $transfer_acceleration  = isset($bucketConfig['transfer_acceleration']) ? $bucketConfig['transfer_acceleration'] : false;
                $access_key             = isset($config['access_key']) ? $config['access_key'] : false;
                $secret_key             = isset($config['secret_key']) ? $config['secret_key'] : false;
                $region                 = isset($config['region']) ? $config['region'] : false;

                if( $access_key==false || $secret_key==false || $region==false || $bucket==false ) return $result;
                
                $currentService = new S3;
                return $currentService->getBucketSecuritySettings($access_key, $secret_key, $region, $bucket, $transfer_acceleration);
                break;
            default: 
                break;  
        }

        return $result;
    }


     /**
     * Change Bucket Public Access
     * @since 1.0.0
     * @param array $data
     */
    public function changePublicAccess($data) {
        $result = [
            'success' => false,
            'message' => esc_html__('Something went wrong', 'media-cloud-sync')
        ];
        
        $service = isset($data['service'])? $data['service'] : false;

        if($service == false) {
            $result = [
                'success' => false,
                'message' => esc_html__('No service selected', 'media-cloud-sync')
            ];
            return $result;
        }

        switch($service){
            case 's3':
                $result = [
                    'success' => false,
                    'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                ];
                $config                 = isset($data['config']) ? $data['config'] : [];
                $bucketData             = isset($data['bucketData']) ? $data['bucketData'] : [];
                if(isset($bucketData['addNew']) && $bucketData['addNew']) {
                    $bucketConfig           = isset($bucketData['addNewConfig']) ? $bucketData['addNewConfig'] : [];
                } else {
                    $bucketConfig           = isset($bucketData['config']) ? $bucketData['config'] : [];
                }
                $bucket                 = isset($bucketConfig['bucket_name']) ? $bucketConfig['bucket_name'] : false;
                $transfer_acceleration  = isset($bucketConfig['transfer_acceleration']) ? $bucketConfig['transfer_acceleration'] : false;
                $access_key             = isset($config['access_key']) ? $config['access_key'] : false;
                $secret_key             = isset($config['secret_key']) ? $config['secret_key'] : false;
                $region                 = isset($config['region']) ? $config['region'] : false;
                $value                  = isset($data['value']) ? $data['value'] : false;

                if( $access_key==false || $secret_key==false || $region==false || $bucket==false ) return $result;
                
                $currentService = new S3;
                return $currentService->changePublicAccess($value, $access_key, $secret_key, $region, $bucket, $transfer_acceleration);
                break;
            
            default: 
                break;  
        }

        return $result;
    }
    
    /**
     * Change bucket ownership
     */
    public function changeObjectOwnership($data) {
        $result = [
            'success' => false,
            'message' => esc_html__('Something went wrong', 'media-cloud-sync')
        ];
        
        $service = isset($data['service'])? $data['service'] : false;

        if($service == false) {
            $result = [
                'success' => false,
                'message' => esc_html__('No service selected', 'media-cloud-sync')
            ];
            return $result;
        }

        switch($service){
            case 's3':
                $result = [
                    'success' => false,
                    'message' => esc_html__('Insufficient Data. Please try again', 'media-cloud-sync')
                ];
                $config                 = isset($data['config']) ? $data['config'] : [];
                $bucketData             = isset($data['bucketData']) ? $data['bucketData'] : [];
                if(isset($bucketData['addNew']) && $bucketData['addNew']) {
                    $bucketConfig           = isset($bucketData['addNewConfig']) ? $bucketData['addNewConfig'] : [];
                } else {
                    $bucketConfig           = isset($bucketData['config']) ? $bucketData['config'] : [];
                }
                $bucket                 = isset($bucketConfig['bucket_name']) ? $bucketConfig['bucket_name'] : false;
                $transfer_acceleration  = isset($bucketConfig['transfer_acceleration']) ? $bucketConfig['transfer_acceleration'] : false;
                $access_key             = isset($config['access_key']) ? $config['access_key'] : false;
                $secret_key             = isset($config['secret_key']) ? $config['secret_key'] : false;
                $region                 = isset($config['region']) ? $config['region'] : false;
                $value                  = isset($data['value']) ? $data['value'] : false;

                if( $access_key==false || $secret_key==false || $region==false || $bucket==false ) return $result;
                
                $currentService = new S3;
                return $currentService->changeObjectOwnership($value, $access_key, $secret_key, $region, $bucket, $transfer_acceleration);
                break;
            
            default: 
                break;  
        }

        return $result;
    }


    /**
     * Get presigned URL
     * @since 1.0.0
     */
    public function get_presigned_url($path) {
        $url_result = $this->service->get_presigned_url($path);
        if(isset($url_result['success']) && $url_result['success']) {
            return isset($url_result['file_url']) ? $url_result['file_url'] : false;
        }
        return false;
    }


    public function uploadSingle($file_path, $source_path, $prefix = '') {
        return $this->service->uploadSingle($file_path, $source_path, $prefix);
    }


    /**
     * Move object to server from cloud
     */
    public function object_to_server($key, $save_path) {
        $path_parts = pathinfo($save_path);
        if (!file_exists($path_parts['dirname'])) {
            mkdir($path_parts['dirname'], 0755, true);
        }
        return $this->service->object_to_server($key, $save_path);
    }

    /**
     * Get the service domain
     * 
     */
    public function get_domain() {
        return $this->service->get_domain();
    }

    /**
     * Ensures only one instance of Class is loaded or can be loaded.
     *
     * @return Service Class instance
     * @since 1.0.0
     * @static
     */
    public static function instance(){
        if (is_null(self::$instance)) {
            self::$instance = new self();
        }
        return self::$instance;
    }
}
```
