Giter VIP home page Giter VIP logo

flyclone's Introduction

Verseles\flyclone

PHP wrapper for rclone

GitHub Actions Workflow Status

supports local disk, dropbox, ftp, sftp, google drive, mega, s3, b2 (any compatible) and others can be easily added via pr.

progress support.

installation

composer require verseles/flyclone

usage

list local files
use Verseles\Flyclone\Rclone;
use Verseles\Flyclone\Providers\LocalProvider;

$left_side = new LocalProvider('mydisk'); // nickname
$rclone = new Rclone($left_side);

var_dump($rclone->ls('/home/')); // returns array
list files from mega server
use Verseles\Flyclone\Rclone;
use Verseles\Flyclone\Providers\MegaProvider;

$left_side = new MegaProvider('myserver',[
    'user'=>'[email protected]',
    'pass'=> Rclone::obscure('applesux')
]);

$rclone = new Rclone($left_side);

var_dump($rclone->ls('/docs')); // returns array
copy from local disk to mega
use Verseles\Flyclone\Rclone;
use Verseles\Flyclone\Providers\LocalProvider;
use Verseles\Flyclone\Providers\MegaProvider;

$left_side = new LocalProvider('mydisk'); // name

$right_side = new MegaProvider('myremote',[
    'user'=>'[email protected]',
    'pass'=> Rclone::obscure('4ppl35u*')
]);

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

$rclone->copy('/home/appleinc/index.html', '/docs'); // always true, otherwise throws error
move from local disk to the same local disk
use Verseles\Flyclone\Rclone;
use Verseles\Flyclone\Providers\LocalProvider;

$samedisk = new LocalProvider('mydisk'); // name

$rclone = new Rclone($samedisk);

$rclone->copy('/home/appleinc/index.html', '/home/www/'); // always true, otherwise throws error
copy to dropbox with progress every sec
use Verseles\Flyclone\Rclone;
use Verseles\Flyclone\Providers\LocalProvider;
use Verseles\Flyclone\Providers\DropboxProvider;

$left_side = new LocalProvider('mydisk'); // nickname
$right_side = new DropboxProvider('myremote', [
    'client_id'     => 'your_dropbox_client_id',
    'client_secret' => 'your_dropbox_client_secret',
    'token'         => 'your_dropbox_token',
]);

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

$rclone->copy('/home/appleinc/index.html', '/home/www/', [], static function ($type, $buffer) use ($rclone) {
   var_dump($rclone->getProgress());
});

tips - read before use.

  • of course, you need known how rclone works.
  • rclone class and providers classes always support any flag listed at rclone documentation, often as 3rd argument. but
  • any flag, parameter or option passed like --parameter-here, in this lib is a array like ['parameter-here'='value', 'max-depth' => 3, 'any'=>'1']
  • if you inform only one provider ('left side'), in commands like copy/move we assume 'right side' as the same 'left side' provider. which means a copying/moving to the same disk.
  • we don't have a great doc for now so open a issue always you have a doubt. remember to be descriptful.

wip to-do

  • add progress support
  • add timeout support
  • add more commands
  • add tests
    • use docker and docker compose for tests
  • send meta details like file id in some storage system like google drive

testing

install docker and docker compose, then run:

cp .env.example .env
make

there are others tests (test_all, test_gdrive, etc), but you'll need fill .env file properly.

contribution

you know how to do that.

license

Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International

flyclone's People

Contributors

insign avatar jaytagdamian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flyclone's Issues

How to setTimeout?

Hi, thank you for this helpful lib!

The default 120s timeout, 100s idleTimeout is not enough for my use case, how can I set custom timeout without modify the library core?
Currently there's only one method for setIdleTimeout, please add setTimeout method.

Public ways to debug

Create a way to debug and check if what was set is what were passed to rclone binary.

Copy from Local Disk to Google Drive

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());
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.