Skip to content

up2share/python-sdk

Repository files navigation

Up2Share API SDK for Python

PyPI version Build Status codecov Documentation Status

This README provides a step-by-step guide on how to use the u2s-sdk to perform a resumable file upload using Python. The u2s-sdk is a library that helps you easily upload large files to the Up2Share platform with resumable uploads.

Prerequisites

Before you get started, ensure you have the following:

  • Python (3.6 or later) installed on your system.
  • Your Up2Share API key (or OAuth token), which you can obtain from your Up2Share account.

Getting Started

  1. Install the required dependencies:

    pip install u2s-sdk
  2. Include the u2s-sdk in your project:

    from u2s_sdk.handler import ResumableUploadHandler
    from u2s_sdk.client import ApiClient
  3. Create an Up2Share ApiClient instance by providing your API key and the base URL:

    api_key = 'your_api_key'
    api_client = ApiClient('https://api.up2sha.re', api_key=api_key, timeout=60)
  4. Initialize the ResumableUploadHandler using the ApiClient:

    handler = ResumableUploadHandler(api_client)
  5. Specify the file you want to upload, the chunk size, and open the file:

    file_name = 'your_file.mp4'
    file_path = 'path/to/your/file/your_file.mp4'
    chunk_size = 1048576  # 1 MB
    
    with open(file_path, 'rb') as file:
        handler.simulate_chunk_upload(file, chunk_size, filename=file_name)
  6. Save and run your Python script.

Uploading Large Files

With this setup, your Python script will upload the specified file to Up2Share using resumable uploads with the given chunk size. The simulate_chunk_upload method automatically takes care of splitting and uploading the file in chunks.

Error Handling

If any issues occur during the upload process, the ResumableUploadHandler class handles exceptions and reports errors in the log.

Development

Install package

pip install -e .

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages