Skip to content

[amuleapi] Add an endpoint to download a shared file's contents over HTTP #659

Description

@ngosang

Feature request

Today the amuleapi REST surface exposes plenty of metadata about files
(GET /api/v0/shared, GET /api/v0/shared/{hash}, GET /api/v0/downloads, …)
but there is no way to retrieve the actual file contents over HTTP.

I would like an endpoint that serves the bytes of a completed file that aMule
already has on disk
, addressed by hash — something like:

GET /api/v0/shared/{hash}/content

Scope, deliberately small:

  • Completed files only. No partial/.part files, no range-into-an-
    incomplete-file logic. If it isn't complete, it isn't downloadable.
  • Shared Files list only. Since finished downloads are moved into the
    incoming directory, which is shared, they already show up in
    GET /api/v0/shared — so a single endpoint under /shared covers both the
    "I finished this download" case and the "this is a file I share" case. No need
    for a second endpoint under /downloads.

Why

The main motivation is the Web UI: with this endpoint I could add a simple
"Download" button next to each row in the Shared Files view (and in the Downloads
view for finished entries, resolving to the same hash), so a user running aMule on
a headless box / NAS / seedbox can grab a finished file straight from the browser,
without SSH/SFTP/Samba or a second file server in front of it.

Right now the Web UI can tell you a file is finished, but you still have to leave
it and use another tool to actually get the file. This closes that gap and makes
the Web UI self-sufficient for remote-aMule users.

Implementation left open

I'm deliberately leaving the implementation to the backend maintainers — you
know the EC/amuleapi internals far better than I do. Anything that ends up as a
plain HTTP GET returning the file body works for me. As a starting point only:

  • URL shape consistent with the existing {hash}-keyed sub-resources
    (/shared/{hash}/verify, /downloads/{hash}/comments, …).
  • Ideally Content-Disposition: attachment; filename="...", Content-Length,
    and Range support so browsers show a real progress bar and can resume — but a
    plain unseekable stream would already be useful.
  • HEAD handled like the other read-only endpoints.

Open questions

  1. amuleapi runs as a separate process talking to amuled/amule over EC,
    so it may not share a filesystem with the core in remote-EC setups. Is it
    acceptable to support only the common same-host case (open the file directly,
    return a clear error otherwise), or should the bytes be streamed through EC?
  2. Security: this turns the API into a file server. It should honour the
    existing session/auth requirements, and must resolve files strictly from the
    shared-files list by hash — never from a user-supplied path.

Happy to do the Web UI side (button + wiring) once the endpoint exists, and to
adapt to whatever URL shape and semantics you settle on.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions