Code Monkey home page Code Monkey logo

brickftp's Introduction

BrickFTP =======

PyPI Python Versions Build Status

Python Client for BrickFTP API (https://developers.brickftp.com/). This client does not implement all the features of the API, pull requests are very welcome to expand functionality.

Installation

To install brickftp, simply:

pip install brickftp

How To Use

Initialise the client

from brickftp import BrickFTP
client = BrickFTP(
    username='[email protected]',
    password='password123',
    subdomain='subdomain',
)

Available methods

NOTE: For each client method, if there is a negative response from the API then BrickFTPError will raise.

List the contents of a folder

client.dir('/some_remote/path')

Upload a file

Upto 5MB supported by the client at this time.

client.upload(upload_path='/some/path.txt', local_path='path.txt')

Download a file

client.download_file(remote_path='/some/path.txt', local_path='path.txt')

Delete a file or folder

NOTE: Deletes recursively through subdirectories.

client.delete('/some_remote/path')

Create a folder

client.mkdir('/some_remote/path')

Requirements

1. Python 3.6+
2. See requirements.txt

Running the tests

Set the environment variables: BRICK_FTP_USER, BRICK_FTP_PASS, BRICK_FTP_SUBDOMAIN.

NOTE: Running the tests against a BrickFTP user will wipe all data on their account.

pip install -r requirements-test.txt
pytest

brickftp's People

Contributors

richardarpanet avatar

Watchers

 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  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

brickftp's Issues

Requests attempts to autoencode PUT request on line 63 of client.py

Currently I'm using the BrickFTP python client to upload files to BrickFTP, the issue arises when I attempt to upload a file containing the character "\u2019", I get the following error:

UnicodeEncodeError: 'latin-1' codec can't encode character '\u2019' in position 89154: Body ('โ€™') is not valid Latin-1. Use body.encode('utf-8') if you want to send it encoded in UTF-8.

I already tried specifying the uft-8 encoding despite it being the default encoding the upload function on line 48 of client.py uses to no avail. After some research I found that the previously mentioned error is because the Requests library attempts to auto-encode what it's uploading based on the first 127 characters of the data. See: https://stackoverflow.com/questions/41030128/str-encoding-from-latin-1-to-utf-8-arbitrarily

I was able to solve this by modifying line 63 of client.py from this:
resp = requests.put(upload_uri, data=input_file.read())

to this:
resp = requests.put(upload_uri, data=input_file.read().encode(encoding))

I will be submitting a PR shortly.

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.