Skip to content

11philip22/mega-up

Repository files navigation

mega-up

C++20 CMake vcpkg MEGA SDK

mega-up is a C++ CLI for uploading local media trees to MEGA.nz. It discovers folders, files, and named glob sets, filters them by media type and size, preserves the requested destination layout, and automatically rotates across newly generated MEGA accounts when the configured per-account quota is reached.

The tool uses the low-level MEGA SDK API directly through MEGA::MegaClient and MEGA::MegaApp. Authentication is automatic: accounts are generated on demand, confirmed through temporary mail, resumed from exported sessions, and used to upload and export public folder links.

Features

  • Upload recursive folders, individual files, and TARGET=GLOB file sets in one run.
  • Preserve folder trees, or use --flat to place folder contents directly in the target folder.
  • Resolve flattened filename collisions deterministically with _2, _3, and so on.
  • Filter videos and images by extension, with case-insensitive matching.
  • Skip zero-byte files and files outside inclusive MiB size bounds.
  • Rotate accounts before a file would exceed the configured quota threshold.
  • Export every top-level target folder and print links grouped by logical target.
  • Warn and continue for missing paths, wrong path types, and empty glob matches.

Prerequisites

  • CMake 3.22 or newer.
  • A C++20 compiler supported by the vendored MEGA SDK.
  • Git submodules initialized for third_party/vcpkg, third_party/meganz-sdk, and third_party/guerrillamail-client-cpp.
  • Network access during configure/build for vcpkg packages, and during runtime for MEGA.nz plus the temporary mailbox provider.

Note

The vendored vcpkg checkout is large. If you already cloned the repository without submodules, initialize them before configuring the build.

Build

git clone --recurse-submodules <repo-url>
cd mega-up
cmake -S . -B build
cmake --build build --target mega-up -j2

If the repository is already cloned:

git submodule update --init --recursive
cmake -S . -B build
cmake --build build --target mega-up -j2

The CLI binary is written to:

./build/mega-up

Usage

mega-up [OPTIONS]

  -f, --folders PATH...       Recursively upload one or more directories
      --files PATH...         Upload one or more individual files
      --file-set TARGET=GLOB  Upload glob matches; repeatable
      --target-folder NAME    Target for files passed with --files
      --min-file-size MB      Minimum file size in MiB (default: 0)
      --max-file-size MB      Maximum file size in MiB (default: 2048)
      --quota GB              Per-account rotation quota in GiB (default: 20)
      --images                Include image extensions
      --videos                Include video extensions
      --flat                  Flatten directory inputs

At least one source option is required: --folders, --files, or --file-set.

Examples

mega-up --folders ./album ./another-album
mega-up --folders ./album --flat
mega-up --files ./a.mp4 ./b.mp4 --target-folder "My Album"
mega-up --file-set "Show=G:\ctbrec\Show*.ts"
mega-up --folders ./album --images --min-file-size 10 --max-file-size 2048

Source Mapping

Source Destination behavior
--folders ./album Creates a top-level album target and uploads matching files recursively.
--folders ./album --flat Creates album, but omits intermediate directories.
--files ./a.mp4 --target-folder Movies Uploads files directly under Movies.
--file-set "Show=./Show*.ts" Uploads matched files directly under Show.

Sources resolving to the same target name are merged in CLI input order. For folder inputs, the target name is the local directory basename. --target-folder and --file-set targets must be a single folder name, not a path.

Filtering

By default, mega-up uploads videos only.

Flags Included media
none Videos
--videos Videos
--images Images
--images --videos Images and videos

Size limits are inclusive and use MiB. A file larger than the configured rotation quota is skipped with a warning, then the remaining candidates continue.

Output

Each target folder is exported separately on every account that contains part of that target. When a target spans accounts, it has one link per account.

Show:
  https://mega.nz/folder/link-A
  https://mega.nz/folder/link-C

Movies:
  https://mega.nz/folder/link-B

Links are grouped by logical target in CLI input order. Links inside each group are listed in account creation order.

Verification

Follow TEST.md for manual end-to-end verification.

Project Layout

src/main.cpp                  CLI parsing and stdout/stderr behavior
src/upload_planner.cpp        Source discovery, filtering, target merging
src/upload_coordinator.cpp    Account rotation and public-link grouping
src/account_generator.cpp     Temporary mailbox signup and session export
src/upload_session.cpp        Low-level MEGA login, folder creation, upload, export
TEST.md                       Manual end-to-end verification
third_party/                  Vendored vcpkg, MEGA SDK, and mailbox client

About

Uploads unlimited files to mega.nz without a subscription

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages