Skip to content

fix: keep the original file name on API, MCP and agent uploads - #2024

Open
giladresisi wants to merge 1 commit into
stagingfrom
fix/keep-original-name-api-uploads
Open

giladresisi wants to merge 1 commit into
stagingfrom
fix/keep-original-name-api-uploads

Conversation

@giladresisi

Copy link
Copy Markdown
Collaborator

What kind of change does this PR introduce?

Bug fix (backend public API, MCP tool, chat agent) plus a small frontend tweak (Media tab tile).
MediaService.saveFile accepts an originalName argument, but only the web-app upload passed it. Every other upload path (POST /public/v1/upload, POST /public/v1/upload-from-url, the MCP uploadFromUrlTool, and the chat agent's image upload in agent.graph.service.ts) now passes it too: the incoming file.originalname for multipart, or the URL's last path segment (query string and hash stripped) for URL-based uploads. Storage naming, the schema, existing rows and the media list endpoints are unchanged.
On the Media tab, the tile name now truncates with an ellipsis and shows the full name on hover instead of overflowing into neighbouring tiles.

Why was this change needed?

A customer who uploads all of their videos through the Postiz agent (MCP) reported that videos in the Media tab show no file name at all, so they cannot tell dozens of similar thumbnails apart, and asked for a way to map their original file names to Postiz media so the agent can find a video by name. The name was simply never stored for API-driven uploads. With this change it is stored the same way as for web-app uploads, so it renders in the Media tab and becomes searchable via the media list search by originalName.

Other information:

URL-derived names are not percent-decoded on purpose: decodeURIComponent throws on malformed escapes and in the public API path that would fail after the file was already uploaded to storage. Rows uploaded before this change keep a null name; no backfill.

QA

  1. With a public API key, run curl -F "file=@./my-test-video.mp4" -H "Authorization: <key>" <backend>/public/v1/upload and confirm the response and the new Media row have originalName = my-test-video.mp4.
  2. POST <backend>/public/v1/upload-from-url with {"url":"https://<host>/path/sample-clip.mp4"}; expect originalName = sample-clip.mp4.
  3. Repeat with .../sample-clip.mp4?token=abc#frag; expect sample-clip.mp4 (query and hash dropped).
  4. Call the MCP uploadFromUrlTool with the URL from step 2; expect the same originalName on the created row.
  5. Open the Media tab: the new tiles show their names, long names end with an ellipsis, and hovering a tile shows the full name. Rows uploaded before this change still show no name.
  6. Upload a file through the Media tab's Upload button; its name still shows as before.

Checklist:

  • I have read the CONTRIBUTING guide.
  • I have signed the Contributor License Agreement (CLA).
  • I confirm I have not used AI to submit this PR or generate code for it.
  • I checked that there were no similar issues or PRs already open for this.
  • This PR fixes just ONE issue
  • I have filled in the QA section above with real steps to verify this change.

🤖 Generated with Claude Code

https://claude.ai/code/session_0113mrwSKBb9jhocwHmgxpJJ

Media.originalName was only set by the web-app upload, so media uploaded
through the public API, the MCP uploadFromUrlTool or the chat agent showed
no name in the Media tab and could not be found by name. Pass the incoming
file name (multipart) or the URL's last path segment (URL uploads).
Also truncate long names on the media tile and show the full name on hover.
@postiz-contribution postiz-contribution Bot added the contribution:approved Approved contributor label Sep 4, 2026
@strix-security

strix-security Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Strix Security Review

No security issues found.

Updated for e252bc0.


Reviewed by Strix
Re-run review · Configure security review settings

@postiz-agent

postiz-agent Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

This branch has not been deployed

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

Labels

contribution:approved Approved contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant