HEX
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.30
System: Linux iZj6c1151k3ad370bosnmsZ 3.10.0-1160.76.1.el7.x86_64 #1 SMP Wed Aug 10 16:21:17 UTC 2022 x86_64
User: root (0)
PHP: 7.4.30
Disabled: NONE
Upload Files
File: /var/www/html/amberconcept/wp-content/plugins/woocommerce-upload-files/classes/com/WCUF_Gdrive.php
<?php 
require WCUF_PLUGIN_ABS_PATH.'/classes/vendor/google/vendor/autoload.php';

class Gdrive
{
	var $gdrive_client;
	var $gdrive_service;
	static $gdrive_filepath_prefix = 'gdrive:'; 
	public function __construct()
	{
		$this->gdrive_client = new Google_Client();
		
		$this->gdrive_client->setDeveloperKey('');
		$this->gdrive_client->setApplicationName("WooCommerce Upload Files");
		$this->gdrive_client->setScopes(Google_Service_Drive::DRIVE);
		$this->gdrive_client->setAccessType('offline');
		
		
		$this->gdrive_service = new Google_Service_Drive($this->gdrive_client );
	}
	public static function is_gdrive_file_path($file_path)
	{
		if(!is_string($file_path))
			return false;
		return strpos($file_path, WCUF_Gdrive::$gdrive_filepath_prefix) !== false ? true : false;
	}
	public function upload_file($filename, $params = array())
	{
		$fileMetadata = new Google_Service_Drive_DriveFile(array('name' => basename($filename)));
		$content = file_get_contents($filename);
		$file = $this->gdrive_service->files->create($fileMetadata, array(
			'data' => $content,
			'mimeType' => mime_content_type($filename),
			'uploadType' => 'multipart',
			'fields' => 'id'
			)
		);
		return $file; 
	}
	
}
?>