import os parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) os.sys.path.insert(0,parentdir) from mfs import loader from mfs.ext import drive import test_config as cfg # Connect to Google Drive drive = loader(drive.FileStorage, key=cfg.drive_key, secret=cfg.drive_secret) # Local file to be uploaded local_file = "test.rst" # Upload file to Google Drive upload = drive.put(local_file) print upload # Download file from Google Drive download_url = upload.get('downloadUrl') download = drive.get(download_url, ".rst") # File-Like object should be closed after completed to delete the temporary file download.close()
import os parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) os.sys.path.insert(0,parentdir) from mfs import loader from mfs.ext import s3 import test_config as cfg # Connect to S3 simple = loader(s3.FileStorage, key=cfg.s3_key, secret=cfg.s3_secret, bucket='mfss3') # Local/Remove file to be uploaded/downloaded fname = "test.rst" # Upload a file to S3 upload = simple.put(fname) print upload # Download a file from S3 download = simple.get(fname) # File-Like object should be closed after completed to delete the temporary file download.close() # Delete file
import os parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) os.sys.path.insert(0,parentdir) from mfs import loader from mfs.ext import drobo import test_config as cfg # Connect to Dropbox dpbox = loader(drobo.FileStorage, key=cfg.dropbox_key, secret=cfg.dropbox_secret, access_token=cfg.dropbox_access) # Local file to be uploaded local_file = "test.rst" # Remote file to be uploaded/downloaded from remote_file = "/test.rst" # Upload file to Dropbox upload = dpbox.put(local_file, remote_file) print upload # Download file from Dropbox download = dpbox.get(remote_file) # File-Like object should be closed after completed to delete the temporary file download.close() # Delete file