Skip to main content

streamlift-megapy

A modern Python client for the MEGA cloud storage service, built for streaming uploads with zero intermediate disk usage.

This package is designed as a drop-in replacement for the unmaintained mega.py package (with upload_stream support), and reimplements the core MEGA client protocol that the megajs npm package uses.

Features

  • Streaming uploads — upload from any file-like object (or async generator) directly to MEGA without writing to local disk.
  • Session restore — log in once, serialize the session, and resume later without a password (useful for long-running workers in ephemeral environments like Google Colab).
  • Sync + async — both a blocking Mega class and an AsyncMega class backed by aiohttp.
  • File management — create folders, delete, move, rename, and generate public share links.
  • Downloads — download public files or logged-in files to disk.
  • Quota — check account storage space and transfer quota.

Installation

pip install -e /path/to/streamlift-megapy
# or, once published:
pip install git+https://github.com/your-org/streamlift-megapy.git

Quick Start

Sync

from streamlift_megapy import Mega

mega = Mega().login("you@example.com", "password")

# Upload a file-like object (zero disk)
with open("movie.mp4", "rb") as f:
    file_node = mega.upload_stream(f, 123456789, "movie.mp4")

# Or upload by path
node = mega.upload("photo.jpg")

# Create + find folders
mega.create_folder("MyFolder")
folder = mega.find("MyFolder")

# Download
mega.download(node, destination="./out/")

# Share link
print(node.link())

Async

import asyncio
from streamlift_megapy import AsyncMega

async def main():
    async with AsyncMega().login("you@example.com", "password") as mega:
        node = await mega.upload_stream(file_obj, file_size, "movie.mp4")

asyncio.run(main())

Session restore

mega = Mega().login("you@example.com", "password")
session_json = mega.to_json()      # safe to persist
sid = mega.sid                     # string SID

# Later, without a password:
mega2 = Mega().login(session=session_json)
# or pass the raw SID string:
mega3 = Mega().login(session=sid)

API Overview

Class Purpose
Mega Sync client (login, upload, download, folders, quota)
AsyncMega Async client (same surface, async def)
File Read-only metadata for any MEGA node / public share
MutableFile Logged-in node with write ops (upload, mkdir, delete, move, rename, link)

Development

pip install -e ".[dev]"
pytest
ruff check mega

License

MIT

Metadata

Release files for streamlift-megapy 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for streamlift-megapy 1.0.0
File Size Uploaded Provenance
streamlift_megapy-1.0.0.tar.gz 38.9 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for streamlift-megapy 1.0.0
File Interpreter ABI Platform
streamlift_megapy-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 71.5 kB

Release files / streamlift_megapy-1.0.0.tar.gz

Download URL streamlift_megapy-1.0.0.tar.gz
Size 38.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ec7693ab3d90113c9f1603031463e11558485974bced7f1402f2c24891907dbf
BLAKE2b-256 checksum
How to use checksums
938b73b15f95c8d8fa25172c734aeb1d3af28cf60e1c82b05ba1c21e34602a6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / streamlift_megapy-1.0.0-py3-none-any.whl

Download URL streamlift_megapy-1.0.0-py3-none-any.whl
Size 32.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9aa137a0e4ffa672c3a9676f12031eac1ce4ee411c1212b0a922f18e1c5df7f4
BLAKE2b-256 checksum
How to use checksums
b88785095817a7f0f87e03fbff56896036e12cba2147960591f4a8ff1f836ec5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Security for streamlift-megapy 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for streamlift_megapy-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page