Git Product home page Git Product logo

multidrive's Introduction

#MultiDrive

Description

Basic utilities to upload and download from various cloud storage services.

Support for Amazon Cloud Drive, Google Drive and Microsoft OneDrive upload and download operations are implemented.

This is in alpha and there may be serious bugs. This has only been tested on Ubuntu, though it should work on Mac OS X. This has not yet been tested in Windows, and may not work in that OS yet without further testing. However, I have received a report that it does work in Windows.

No API keys are provided. You will need to sign up as a developer with each service providers to get keys.

Next Planned Features:

  • Cleaned up debug output
  • More robust OneDrive uploads
  • Progress display for uploads and downloads.
  • More robust handling of Hash errors.

Usage

./multidrive -h

Displays help

./multidrive -s googledrive -a upload -l example.txt

Uploads "example.txt" to the root directory on Google Drive.

./multidrive -s googledrive -a upload -l example.txt -r examplefolder

Uploads "example.txt" to the "examplefolder" directory on Google Drive.

./multidrive -s googledrive -a upload -l example.txt -r examplefolder -c

Uploads "example.txt" to the "examplefolder" directory on Google Drive. It will create the remote folder if necessary

./multidrive -s googledrive -a download -r "example.txt" 

Downloads "example.txt" in the root directory of Google Drive to the local computer.

./multidrive -s googledrive -d onedrive -a copy -r "Source Folder" -e "Transfers" -c

Copies the contents of "Source Folder" on Google Drive to the "Transfers" folder on Microsoft OneDrive, creating the remote folder if necessary. The program will get a list of files, then, transfer one file at a time to the other service by downloading it to the local machine, then uploading it again.

Current Functionality

Google Drive OneDrive Cloud Drive Dropbox
Authentication
Authenticate user Yes Yes Yes Pending
Basic File Operations
Upload File Yes Yes Yes Pending
Upload Folder Yes Yes Yes Pending
Download File Yes Yes Yes Pending
Download Folder Yes Yes Yes Pending
Advanced
Get Modified Time Yes Partial Partial Unknown
Set Modified Time Yes No No Unknown
Local Overwrite Yes Yes Yes Pending
Remote Overwrite Yes Yes Yes Pending
Local Destination Folder Yes Yes Yes Pending
Remote Destination Folder Yes Yes Yes Pending
List Remote Files Yes Yes Yes Pending
Create Remote Folder Yes Yes Yes Pending
List Quota Yes Yes Yes Pending
Delete Remote File Pending Pending Pending Pending
Copy Folders Yes Yes Yes Pending
Verify Files by Hash Yes Yes Yes Pending

Updates

2015-04-27 0.1.21: Upload command now supports folder upload.

2015-04-12 0.1.20: Add additional debug logging.
Add version display to help message

2015-04-10 0.1.19: OneDrive: Add additional timeouts and upload status messages.

2015-04-09 0.1.18: OneDrive: Can now resume uploads using upload status.

2015-04-08 0.1.17: Bug Fix: Fixed logging for OneDrive upload errors
Added timeout to deal with hanging OneDrive downloads.

2015-04-08 0.1.16: Bug Fix: Amazon Cloud Drive should work again on 32-bit systems for files larger than 4GiB
Added logging to better handle OneDrive upload errors.

2015-04-07 0.1.15: Bug Fix: OneDrive chunk size updated. Should now work for files larger than 7.6GiB (up to 10GiB)

2015-04-06 0.1.14: Bug Fix: Google Drive should now resume properly on a Hash Mismatch

2015-04-05 0.1.13: Improved Quota Output for Google Drive and Cloud Drive.
Bug Fix: OneDrive authentication should work again.
OneDrive: Preparation for implementation of AppFolder functionality. On hold while OneDrive API issues examined.

2015-04-04 0.1.12: Cloud Drive: Improved Quota Output. Now lists usage for various categories, even if it doesn't use quota.
Bug Fix: OneDrive: If OneDrive server reports that the fragment has already been sent, send the next one. Will need to monitor for this rare issue to see if this can be improved upon.

2015-04-04 0.1.11: Update Readme Bug Fix: Google Drive: ' filename issue should now be fixed properly.

2015-04-04 0.1.10: Bug Fix: OneDrive: Fixed debug message for uploads
Bug Fix: Google Drive: Uploads and queries for files with a ' in the name should now work.

2015-04-04 0.1.9: New Feature: Quota for each account type can now be listed

2015-04-04 0.1.8: Fixed issue with downloading/listing Google Drive folders with more than 100 items.
Minor changes to debug code.

2015-04-03 0.1.7: Bug Fix: Cloud Drive HTTP retry code fixed
Additional OneDrive retry code added.

2015-04-02 0.1.6: Additional retry code added, particularly on hash and connection failures
Bug Fixes

2015-04-02 0.1.5: Attempt Retry on UnicodeDecodeError on Cloud Drive
Fixed Retry code for OneDrive/CloudDrive
Bug Fixes

2015-04-01 0.1.4: Added Hash check upon upload and download to confirm files properly transferred.
Bug Fixes

2015-04-01 0.1.3: Refactored Cloud Drive Service class to reduce access token requests and improve http request handling.
Refactored OneDrive HTTP requests for robustness.
Bug Fixes

2015-03-31 0.1.2: Refactored OneDrive Service class. It should be faster now, with less requests going to the server.
Bug Fixes

2015-03-31 0.1.1: Added debug option (-b)
Bug Fixes

2015-03-30 0.1.0: Changed to Python 3 to try to allow 32-bit systems to upload files greater than 4GB in size to Cloud Drive.
Removed PyDrive as it is not supported in Python 3.
Added new authenticaion method for Google Drive due to removal of PyDrive. You'll need to rename the client_secrets.json file to google_drive_client_secrets.json and reauthenticate.
Added prompt to acknowledge risks if malware detected by Google Drive
Bug Fixes

Known issues

An error may be returned if uploading a file greater than 10GB to Amazon Cloud Drive. A report with Amazon has been filed. The file appears to upload properly after a short delay.

A possibly related issue is that downloading a file greater than 10GB is not supported from Amazon Cloud Drive. It's unclear if it's currently possible to download these files.

Requirements

Requires the httplib2, python-dateutil, google-api-python-client, requests, and requests-toolbelt libraries.

requests-toolbelt version 4.0.0 or later is required for OneDrive uploads. This was released on 2015-04-03.

google-api-python-client now supports Python 3, though it requires an updated httplib2 module not available in pip. This can be installed from source.

This can be installed by running: wget https://github.com/jcgregorio/httplib2/archive/master.zip unzip master.zip cd httplib2-master python3 ./setup.py install pip install google-api-python-client pip install requests pip install requests-toolbelt pip install python-dateutil

Google Drive setup

Go to https://code.google.com/apis/console with your Google Account.

Create a new project. Under API's and Auth, enable the Drive API. In Credentials: Create a new Client ID for an "Installed Application" Download the JSON file, put it in the working directory and name it google_drive_client_secrets.json

Credentials are stored in google_drive_settings.dat after authentication.

OneDrive Setup

Sign up for API key (TODO: Add instructions)

Create a file onedrive_client_secrets.json with the following information (insert your client id and secret):

{"client_id": "000000001234ABCD", "client_secret":"cL1eNtS3cr3T60eSHere01234567890A"}

Cloud Drive Setup.

Sign up for API key. See https://developer.amazon.com/public/apis/experience/cloud-drive/content/getting-started

Create a file cloud_drive_client_secrets.json with the following information (insert your client id and secret, as well as your Return URL):

{"client_id": "amzn1.application-oa2-client.000000001234ABCD", "client_secret":"cL1eNtS3cr3T60eSHere01234567890A", "return_uri":"https://example.com/login"}

Planned features

Support for Dropbox is planned. Support for handling quota errors. When downloading/uploading folders, if overwrite is disabled, check to see if there are any file conflicts before starting operations Support keeping track of last modified time on platforms that support it (Supported for Google Drive, limited support on Amazon Cloud Drive and Microsoft OneDrive). Deal with Google's versions feature when overwriting files. Support for OneDrive's experimental upload from URL feature. This could speed up transfers to OneDrive from other services that provide a public URL for files (Currently just Amazon Cloud Drive and Dropbox.

Licence

GPL v3

See licence file for details

THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM β€œAS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES

multidrive's People

Contributors

lyrrad avatar

Stargazers

Robert Gorrie avatar Brad Clare avatar Guillaume Ausset avatar Vaibhaw Singh Chandel avatar  avatar Justin Kromlinger avatar nfd (aka alex) avatar Vishav Kandola avatar  avatar  avatar Austin avatar Vinny Furia avatar Danzig avatar Jessie Wincek avatar Brian Reinhart avatar Christopher Mejo avatar Yuriy Linnyk avatar  avatar Sven avatar Nicholas Ramsey avatar Pablo Alexandre avatar Zack M. Davis avatar Ameir Abdeldayem avatar Floris van Lint avatar  avatar Robert Scullin avatar Issam Chajii avatar Dan Hallock avatar  avatar Mike Weaver avatar  avatar  avatar Odem avatar

Watchers

Chris Seltzer avatar  avatar Sven avatar Danzig avatar  avatar Odem avatar  avatar

multidrive's Issues

"OverflowError: cannot fit 'int' into an index-sized integer" revisited...

I'd like to say that your multidrive work is incredible. This is exactly what I've been looking for on Linux, and it is truly useful. Thank you so much for doing this!

Unfortunately I'm running into a different issue with uploading large files on a 32-bit system than you originally reported/worked on regarding the "requests-toolbelt" encoder. I was hoping you might have some insight. I'm a relative newbie in terms of Python, and after spending a lot of time digging into the requests-toolbelt encoder, I'm finding that this "len" issue is beyond my capabilities at the present time.

I'm using multidrive on a 32-bit Linux system (running Ubuntu 14.04), and I've pulled down and installed the latest requests-toolbelt package (0.4.0), requests 2.6.0, etc.

With the latest requests-toolbelt (including the "bug/80" fix), multidrive can upload a 4GB file (for example) to Google Drive without an issue. Unfortunately however uploading the same file to Cloud Drive fails with an "int" OverflowError involving "len". This is the traceback that I get:

test@gandalf:~/projects/multidrive$ python3 multidrive.py -s clouddrive -a upload -l ./testfile
Traceback (most recent call last):
  File "multidrive.py", line 199, in <module>
    main()
  File "multidrive.py", line 89, in main
    overwrite=args.overwrite)
  File "/home/test/projects/multidrive/clouddrivestorageservice.py", line 390, in upload
    multipart_hash_file=cur_hash_file)
  File "/home/test/projects/multidrive/clouddrivestorageservice.py", line 135, in http_request
    data = MultipartEncoder(fields=multipart_encoder_fields)
  File "/usr/local/lib/python3.4/dist-packages/requests_toolbelt-0.4.0-py3.4.egg/requests_toolbelt/multipart/encoder.py", line 120, in __init__
  File "/usr/local/lib/python3.4/dist-packages/requests_toolbelt-0.4.0-py3.4.egg/requests_toolbelt/multipart/encoder.py", line 241, in _prepare_parts
  File "/usr/local/lib/python3.4/dist-packages/requests_toolbelt-0.4.0-py3.4.egg/requests_toolbelt/multipart/encoder.py", line 241, in <listcomp>
  File "/usr/local/lib/python3.4/dist-packages/requests_toolbelt-0.4.0-py3.4.egg/requests_toolbelt/multipart/encoder.py", line 453, in from_field
  File "/usr/local/lib/python3.4/dist-packages/requests_toolbelt-0.4.0-py3.4.egg/requests_toolbelt/multipart/encoder.py", line 446, in __init__
  File "/usr/local/lib/python3.4/dist-packages/requests-2.6.0-py3.4.egg/requests/utils.py", line 52, in super_len
    return len(o)
OverflowError: cannot fit 'int' into an index-sized integer
test@gandalf:~/projects/multidrive$

Do you have any ideas? Anything that you could do to help address this would be so awesome...again your work here is simply too cool.

Thanks!!

Progress is not displayed

It would be nice if download/upload progress was displayed. That would make this a lot more usable.

I'm not sure what that would entail, but it would sure be helpful.

" in the filenames isn't escaped correctly

" in the filenames isn't escaped correctly.

$ ./multidrive.py -s onedrive -a upload -l "test\"file.txt"
Retry 1
Upload Chunk: Connection failed Code: 400
Error: {"error":{"code":"invalidArgument","message":"Bad Argument","innererror":{"code":"badArgument"}}}
Headers: {'X-WLSPROXY': 'DM2302____PAP110', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains, max-age=31536000; includeSubDomains', 'Content-Type': 'application/json; charset=utf-8', 'Server': 'Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0', 'Content-Length': '97', 'Date': 'Sun, 21 Jun 2015 02:51:22 GMT', 'X-MSNSERVER': 'BY3301____PAP080', 'X-AsmVersion': 'UNKNOWN; 19.21.0.0', 'Via': '1.1 DM2302____PAP110 (wls-colorado)', 'X-QosStats': '{"ApiId":0,"ResultType":2,"SourcePropertyId":0,"TargetPropertyId":42}', 'X-ThrowSite': '3e22.bb0a', 'P3P': 'CP="BUS CUR CONo FIN IVDo ONL OUR PHY SAMo TELo"'}
Waiting 1.0 second(s) for next attempt
Got error {"error":{"code":"invalidRange","message":"Uploaded fragment overlaps with existing data.","innererror":{"code":"fragmentOverlap"}}}
DEBUG: Getting upload status
Current Chunk  Start: 0
Status: {'nextExpectedRanges': [], 'expirationDateTime': '2015-06-28T02:51:22.5288845+00:00'}
Traceback (most recent call last):
  File "./multidrive.py", line 235, in <module>
    main()
  File "./multidrive.py", line 125, in main
    overwrite=args.overwrite)
  File "/home/buchno/git/other/multidrive/onedrivestorageservice.py", line 400, in upload
    [0].split("-")[0])
IndexError: list index out of range

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.