Skip to main content

A Jupyter file widget with chunked upload capabilities

Project description

ipyuploads

ipyuploads is a Jupyter file widget with a variety of improvements over the FileUpload component that comes in ipywidgets. It is designed to serve as a drop-in replacement for the aforementioned component. Features include:

  • Progress indicator on uploads over 1 mb
  • "Chunked" file upload supports larger files than FileUpload allows
  • The ability to write chunks to disk reduces the memory requirement for large file uploads
  • Callback hooks on file upload completion, chunk upload completion and all-files completion

Requirements

  • ipywidgets >= 7.5.0

Installation

pip install ipyuploads

Development

git clone https://github.com/g2nb/ipyuploads.git
pip install -e ipyuploads

Usage

In a Jupyter notebook, run the following:

import ipyuploads

ipyuploads.Upload()

Various options can also be set, including:

import ipyuploads

ipyuploads.Upload(accept='txt',           # Accept only text files
                  multiple=True,          # Upload multiple files at once
                  disabled=True,          # Disable the widget
                  icon='cloud-upload',    # Change the upload icon
                  button_stye='primary',  # Change the button style
                  error='Bad Error',      # Set the error message
                  busy=False,             # Whether an upload is in progress
                  chunk_complete=foo,     # Callback when a chunk upload completes
                  file_complete=bar,      # Callback when a file upload completes
                  all_files_complete=baz, # Callback when all files complete
                  custom_path=custom_path # Custom path to upload
                  )

The three callback functions defined above should have the following structure:

def chunk_complete(name, count, total):
    """Callback to be executed when a chunk finishes uploading
    
       name - Name of the file being uploaded
       count - A counter of which chunk just finished uploading
       total - The total number of chunks in this file"""
    print(f'CHUNK CALLBACK! {name} {count} {total}')

def file_complete(name):
    """Callback to be executed when a file finishes uploading
    
       name - Name of the file that was just uploaded"""
    print('FILE CALLBACK! ' + name)

def all_files_complete(names):
    """Callback to be executed once all selected files finish uploading
    
       names - A list of metadata objects, one for each file. Each contains:
                   { 'name': 'the file's name', 
                     'type': 'mime-type of the file', 
                     'last_modified': last modified data as an integer 
                                      (number of milliseconds since the epoch) }"""
    print(f'ALL FILES CALLBACK! {names}')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ipyuploads-0.2.3.tar.gz (30.0 MB view details)

Uploaded Source

Built Distribution

ipyuploads-0.2.3-py3-none-any.whl (108.8 kB view details)

Uploaded Python 3

File details

Details for the file ipyuploads-0.2.3.tar.gz.

File metadata

  • Download URL: ipyuploads-0.2.3.tar.gz
  • Upload date:
  • Size: 30.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for ipyuploads-0.2.3.tar.gz
Algorithm Hash digest
SHA256 d25ca6fd84f2de47e5da149c35b118b53885e5cade09106f850f0e751135fc32
MD5 881396d1bff7d2f2fe55fb513d4ab7d3
BLAKE2b-256 29d35068939faccb1e6014cec58383d546b04095ac85b386c01fb29982b93da2

See more details on using hashes here.

File details

Details for the file ipyuploads-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: ipyuploads-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 108.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for ipyuploads-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fac305971a6e85e6bb5f4bfa9df219da94a08076cd6e2f2554c16beebbd2a49d
MD5 f5d21472565cbc6ade142e38d428b97b
BLAKE2b-256 823fe68f82ac2f7ff8377072e149dfbc0800666e46f8703f2a51a858f077bd3b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page