-
Notifications
You must be signed in to change notification settings - Fork 7
/
SugarSyncUploader.php
41 lines (38 loc) · 1.09 KB
/
SugarSyncUploader.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
include_once __DIR__.'/../SugarSync/SugarSync.php';
/*!
Uploads the backup to SugarSync using login (e-mail) and password
also you will need
accessKeyId and privateAccessKey which you can get from
it is insecure to store login and password on the server so it will be replaced with OAuth version
*/
class SugarSyncUploader implements IUploader{
public $dir;
public $sugar;
/*!
@param array $prefs
array("login"=>"test@test.ru",
"pass"=>'test',
"dir"=>'/Backups',
"accessKeyId"=>"AAAAAAAAAAAAAAAAAAAAAAAAAAA",
"privateAccessKey"=>"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
)
*/
function __construct($prefs){
extract($prefs);
if(empty($login)||empty($pass)){
throw new Exception("You had missed arguments about server");
}
$this->sugar=new SugarSync($login,$pass,$accessKeyId,$privateAccessKey);
static::checkServerRequisites($dir);
}
function checkServerRequisites($dir){
$this->sugar->chdir($dir,'/');
$this->dir=$dir;
}
function upload(string $fileName,string $as){
//$this->sugar->chdir($dir,'/');
$this->sugar->upload($fileName,$as);
}
};
?>