IPython file upload widget
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
fileupload
.eslintrc fixes #4 Feb 18, 2016
.gitignore initial commit, scaffold May 11, 2015
ChangeLog
README.rst Added binder badge Mar 26, 2018
dev-requirements.txt update setup.cfg, add dev requirements Feb 14, 2016
requirements.txt
setup.cfg clarify README.rst, fix setup.cfg Aug 16, 2017
setup.py add view and model May 19, 2015

README.rst

IPython File Upload

Latest Version Downloads Binder

An IPython notebook widget to upload files, using FileReader.

Installation

Install using pip:

pip install fileupload

Install JavaScript:

jupyter nbextension install [--user] --py fileupload

Enable the extension:

jupyter nbextension enable [--user] --py fileupload

Usage

import io
from IPython.display import display
import fileupload

def _upload():

    _upload_widget = fileupload.FileUploadWidget()

    def _cb(change):
        decoded = io.StringIO(change['owner'].data.decode('utf-8'))
        filename = change['owner'].filename
        print('Uploaded `{}` ({:.2f} kB)'.format(
            filename, len(decoded.read()) / 2 **10))

    _upload_widget.observe(_cb, names='data')
    display(_upload_widget)

_upload()

Base64 data is synced to the data_base64 member, decoded data can be obtained from data. The name of the uploaded file is stored in filename.

Changelog

Refer to Changelog.