megalib 0.9.0

Rust client library for Mega.nz cloud storage
Documentation

megalib

Crates.io Documentation License: MIT PRs Welcome

A Rust client library for the MEGA cloud storage service.

This library provides a clean, asynchronous Rust interface for interacting with MEGA, supporting authentication, filesystem access, and file management.

Features

  • Authentication:

    • Full registration flow (account creation + email verification)
    • Login (supports both v1 and v2/PBKDF2 authentication)
    • Session management and caching
    • Password Change (change_password)
  • Filesystem:

    • Fetch filesystem tree
    • List files and directories
    • Get node information (stat)
    • Create directories (mkdir)
    • Remove files/folders (rm)
    • Rename files/folders (rename)
    • Move files/folders (mv)
    • Access Public Folders (open_folder)
  • File Transfer:

    • File upload with optional resume support
    • File download with resume support
    • Parallel transfer workers support
    • Progress callbacks for monitoring transfers
    • Text/Video/Image streaming support
    • Automatic thumbnail generation on upload
    • Public link generation (export, export_many)
    • Proxy support (HTTP/HTTPS/SOCKS5)
  • Node Operations:

    • Get node by handle
    • Check ancestor relationships
    • Check write permissions
  • Sharing & Contacts:

  • Share folders with other users by path (share_folder)

    • List contacts (list_contacts)
    • Access incoming shared folders

Installation

Add this to your Cargo.toml:

[dependencies]
megalib = "0.8.1"
tokio = { version = "1", features = ["full"] }

Quickstart

Minimal login + list to confirm everything works:

use megalib::SessionHandle;

#[tokio::main]
async fn main() -> megalib::Result<()> {
    let session = SessionHandle::login("user@example.com", "password").await?;
    session.refresh().await?;

    // Cloud Drive paths are rooted at /Root
    for node in session.list("/Root", false).await? {
        println!("{} ({} bytes)", node.name, node.size);
    }

    Ok(())
}

More Examples

cargo run --example <name> -- <args>

Suggested starting points: login, ls, upload, download, upload_resume, download_resume, export, share, folder, download_public, upload_bytes, upload_reader. See examples/ for the full list and example-specific flags.

Documentation

For detailed API documentation, visit docs.rs/megalib.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/cool-feature)
  3. Commit your changes (git commit -m 'Add some cool feature')
  4. Push to the branch (git push origin feature/cool-feature)
  5. Open a Pull Request

Support

If this crate saves you time or helps your work, support is appreciated:

Ko-fi

License

This project is licensed under the MIT License; see license for details.

Disclaimer

This is an unofficial client library and is not affiliated with, associated with, authorized by, endorsed by, or in any way officially connected with Mega Limited.