File: test.php

package info (click to toggle)
rclone 1.69.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 45,716 kB
  • sloc: sh: 1,115; xml: 857; python: 754; javascript: 612; makefile: 299; ansic: 101; php: 74
file content (55 lines) | stat: -rw-r--r-- 1,275 bytes parent folder | download | duplicates (4)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/*
Test program for librclone
*/

include_once ( "rclone.php" );

const REMOTE    = 'gdrive:/';
const FOLDER    = "rcloneTest";
const FILE      = "testFile.txt";

$rc = new Rclone( __DIR__ . '/librclone.so' );

$response = $rc->rpc( "config/listremotes", "{}" );
print_r( $response );

$response = $rc->rpc("operations/mkdir",
    json_encode( [
        'fs' => REMOTE,
        'remote'=> FOLDER
    ]));
print_r( $response );

$response = $rc->rpc("operations/list",
    json_encode( [
        'fs' => REMOTE,
        'remote'=> ''
    ]));
print_r( $response );

file_put_contents("./" . FILE, "Success!!!");
$response = $rc->rpc("operations/copyfile",
    json_encode( [
        'srcFs' => getcwd(),
        'srcRemote'=> FILE,
        'dstFs' => REMOTE . FOLDER,
        'dstRemote' => FILE
    ]));
print_r( $response );

$response = $rc->rpc("operations/list",
    json_encode( [
        'fs' => REMOTE . FOLDER,
        'remote'=> ''
    ]));
print_r( $response );
if ( $response['output'] ) {
    $array = @json_decode( $response['output'], true );
    if ( $response['status'] == 200 && $array['list'] ?? 0 ) {
        $valid = $array['list'][0]['Name'] == FILE ? "SUCCESS" : "FAIL";
        print_r("The test seems: " . $valid . "\n");
    }
}

$rc->close();