verseles / flyclone

PHP wrapper for rclone. Supports Local disk, Dropbox, FTP, SFTP, Google Drive, MEGA, S3 (any compatible) and others. Progress support.
Other
71 stars 5 forks source link

Copy from Local Disk to Google Drive #1

Closed Gosokan closed 2 years ago

Gosokan commented 3 years ago

Please give example usage to copy from local disk to google drive.

-- update ---

this is the same as the usage example for copy local to dropbox

<?php
require('./vendor/autoload.php');

use CloudAtlas\Flyclone\Rclone;
use CloudAtlas\Flyclone\Providers\LocalProvider;
use CloudAtlas\Flyclone\Providers\GDriveProvider;

$left_side = new LocalProvider('localdisk'); // nickname
$right_side = new GDriveProvider('tbox-sh-unli-root', [
    'CLIENT_ID'     => 'COPY client_id VALUE FROM rclone.conf',
    'CLIENT_SECRET' => 'COPY client_secret VALUE FROM rclone.conf',
    'TOKEN'         => 'COPY token VALUE FROM rclone.conf',
]);

$rclone = new Rclone($left_side, $right_side);

$rclone->copy('/path/to/files/or/dir', '/remote/path', [], static function ($type, $buffer) use ($rclone) {
   print_r($rclone->getProgress());
});
insign commented 3 years ago

Hi, this code worked fine to you?

Gosokan commented 3 years ago

Yes this code is work fine in terminal:

user@host:~$ php phpfilename.php

result:

stdClass Object
(
    [raw] =>
    [dataSent] => 0
    [dataTotal] => 0
    [sent] => 0
    [speed] => 0
    [eta] => 0
)
stdClass Object
(
    [raw] => 3.090M / 71.783 MBytes, 4%, 2.349 MBytes/s, ETA 29s
    [dataSent] => 3.090M
    [dataTotal] => 71.783 MB
    [sent] => 4
    [speed] => 2.349 MB
    [eta] => 29s
)
...
...
stdClass Object
(
    [raw] => 71.783M / 71.783 MBytes, 100%, 15.115 MBytes/s, ETA 0s
    [dataSent] => 71.783M
    [dataTotal] => 71.783 MB
    [sent] => 100
    [speed] => 15.115 MB
    [eta] => 0s
) 

But still haven't found a way to make the process displayed in the browser using php and ajax.

insign commented 2 years ago

why not?

insign commented 2 years ago

As there were no responses, I am closing for now.