← Back to Pull requests

Share files and folders by link, to look at or to download, and turn a link off any time #148

Closed
unknown closed this pull request without merging on Nov 24, 2026 01:21 UTC
View on GitHub
unknown unknown commented on Nov 23, 2026 23:02 UTC
Author

Why

There was no way to show somebody outside the household a folder of photos or a file without giving them an account. This adds links anyone can open without signing in: view only, or view and download. A link can be changed or turned off at any time, and stops working at once.

What changed

For the person sharing

  • In My files, ticking files or folders, or opening a file's details, now offers Share…. The dialog creates the link, shows it with Copy link, switches between view only and view and download, and has Stop sharing. Things ticked together share one link. Sharing the same set again returns the same link rather than a second one.

  • A new Shared links page in the sidebar lists every link: what it shares and where, whether it allows downloads, and when it was made. It has Copy, Open, an access switch and Stop sharing on each.

  • Shared rows in My files show a small link icon. The delete dialog says when deleting will stop a link.

  • While this Uncloud can't be reached from outside (no PublicUrl and no tunnel), the dialog and the page say nobody else can open links yet. Admins get a way into Settings.
  • For whoever has the link (/s/<token>, no account)

  • A page of its own. A single folder opens straight into it, several items show as a list, and a single file is the page itself. Visitors can browse folders, see folder sizes, and step through files with arrow keys.

  • Pictures, video, audio, PDFs and text are shown on the page. Text is fetched and put on the page as text, never as markup. Anything else says it can't be shown here.

  • With view and download, every file has a download button, and there's Download all or Download this folder as a zip.
  • Server

  • New share_links table in homebase.db, and ShareLinks in Homebase.Core/Sharing. A link is found by the SHA-256 of a 32-byte random token, as sessions are. The token is also kept sealed under host.key (AES-GCM, bound to owner and link id), only so its owner can copy it again.

  • Owner endpoints (session required): GET/POST /api/shares, PATCH/DELETE /api/shares/{id}. Another account gets 404 for links that aren't theirs.

  • Anonymous endpoints: /api/shared/{token} plus /files, /size, /file (inline preview), /download and /zip. The last two are refused with 403 on a view-only link.

  • /api/files/move and /rename carry links along with what moved. /delete drops whatever is gone from links, checked per path after the delete, so a delete that stops partway still lets go of what went. A link left with nothing is removed.

  • Folder zips stream as they're read (LibraryService.ZipAsync). .NET 10's ZipArchive still writes its data descriptors and central directory synchronously, which Kestrel refuses. A small DeferredWrites stream holds those bytes and sends them ahead of the next async write. I measured at most 207 bytes held while zipping a 5 MB file, so the file data itself streams.
  • For reviewers


  • What gets shown inline is an allowlist (SharePreview). It's served inline with nosniff and a CSP of default-src 'none' plus sandbox. PDFs have no sandbox, because Chrome's viewer won't open under it; they get frame-ancestors 'self' so the page's iframe works. HTML, SVG and everything else get 415 from /file and are only ever downloaded. That keeps the existing rule that nothing anybody stores runs on Uncloud's origin, which matters because a visitor may be signed in to this Uncloud in the same browser.

  • Path containment: a visitor's path must start with the public name of a shared item. The rest goes through PathPolicy under that item, so .., hidden names and links are refused. Tests try a list of escapes against all four file endpoints.

  • Missing and turned-off links look the same. A link that never existed, one turned off, and one whose owner is disabled all return the same 404. Deleting an account cascades its links away.

  • Where the link points: PublicUrl or the tunnel, falling back to the address the page was opened at. reachable: false drives the "nobody else can open links yet" note.

  • View only is soft by nature, and the dialog says so: no download buttons, no right-click save on pictures and players, and #toolbar=0 for Chrome's PDF viewer. Anything shown can still be kept, with a screenshot say.

  • Known gap, documented: Uncloud doesn't see renames or deletes made on a synced computer. A link to such a path keeps pointing at that path, so it would share whatever is put there under that name next. The owner's list marks items that are no longer there.

  • /s and /api/shared responses carry X-Robots-Tag: noindex. Referrer-Policy: no-referrer was already global.
  • Tests


  • ./scripts/check.sh passed: web 190 (7 new), .NET 519 (9 new), plus the node and Swift suites. Go isn't on PATH on this machine, so the tunnel build was skipped; this PR doesn't touch it.

  • New ShareTests.cs:

  • - A view-only folder shows to an anonymous client with nothing downloadable. A picture comes back inline with sandbox, and HTML gets 415.
    - No path reaches beside, above, hidden or through a link.
    - Zips include nested folders and empty ones, and leave out hidden entries and links.
    - Only the owner can list, change or turn off a link, and nothing works without a session.
    - Sharing the same set twice returns one link.
    - Links follow rename and move, drop what's deleted, and don't come back on restore.
    - A disabled owner turns links off and re-enabling turns them back on. A deleted account removes them.
    - The link uses PublicUrl when set, and reports reachable false without it.
  • New sharing.test.tsx covers:

  • - Creating a link (view only by default), copying it, and the shared mark appearing.
    - Changing access and stopping a link.
    - The note when nothing outside can reach the host.
    - The delete warning when something inside a folder is shared.
    - The visitor page in view-only and download modes.
    - The visitor's page for a link that doesn't work.
  • I flipped the view-only page to show download buttons, and the view-only test failed as it should.

  • Tried in a browser on a throwaway local host:

  • - Folder, several-item and single-file links.
    - Photos, the PDF, text, refused HTML and audio in the viewer.
    - Switching to view and download, then a real zip and download through Kestrel.
    - Stopping a link, then the visitor's page saying it doesn't work.
    - Dark mode.
  • Not tried: video (no sample to hand), HEIC in Safari, Firefox or Safari in general, and a link over the real tunnel.
  • 🤖 Generated with Claude Code

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: ethanteng Review duration: 138m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #148"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.5% · Safe to merge
    22.5%