Skip to content

Preserve original filename when opening cura:// URLs#21537

Open
Nikolay Zinov (nzinov) wants to merge 1 commit into
Ultimaker:mainfrom
nzinov:fix-opened-url-filename
Open

Preserve original filename when opening cura:// URLs#21537
Nikolay Zinov (nzinov) wants to merge 1 commit into
Ultimaker:mainfrom
nzinov:fix-opened-url-filename

Conversation

@nzinov
Copy link
Copy Markdown

@nzinov Nikolay Zinov (nzinov) commented Apr 13, 2026

When a model is opened via a cura://open?file=… URL (e.g. Thingiverse's "Send to Cura" button), the downloaded file is shown in Cura with a name like tmpAbC123model.stl instead of model.stl.

The handler in CuraApplication._openUrl already does the work to recover the real filename — it parses the Content-Disposition header, and falls back to the last URL path segment. But it then passes that name as the suffix argument to tempfile.NamedTemporaryFile, which produces tmpXXXXXX<suffix>. So the careful filename extraction is effectively wasted.

This PR writes the download to a fresh temp directory under its real filename instead. The temp file is still disposable, but the name Cura displays (and suggests on save) is now the original model name.

Before / after

  • Before: tmpAbC123thingiverse_123456_model.stl
  • After: thingiverse_123456_model.stl

The on_finish handler in CuraApplication._openUrl carefully extracts the
original filename (from Content-Disposition or the URL path), but then
passes it as the 'suffix' argument to tempfile.NamedTemporaryFile, which
produces a file named 'tmpXXXXXX<filename>' — so the name shown in Cura
(and suggested on save) is something like 'tmpAbC123model.stl'.

Write the download to a fresh temp directory under its real filename
instead. Users opening models from Thingiverse's 'Send to Cura' (and
anything else using the cura:// URL scheme) now see the actual model
name.
@github-actions github-actions Bot added the PR: Community Contribution 👑 Community Contribution PR's label Apr 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Test Results

24 572 tests  ±0   24 570 ✅ ±0   51s ⏱️ +4s
     1 suites ±0        2 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit 10c0661. ± Comparison against base commit e0f5d83.

@casperlamboo
Copy link
Copy Markdown
Contributor

Hi Nikolay Zinov (@nzinov) thank you for the PR, seems like useful addition. Could you share how this feature has been tested? I do recall our team trying something like this, but running into the issue where tempfolders would be cleared before we could load them where tempfiles would not.

@nzinov
Copy link
Copy Markdown
Author

Casper Lamboo (@casperlamboo) I use it locally on my machine without any problems for a while now, but I have not tested it otherwise.

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

Labels

PR: Community Contribution 👑 Community Contribution PR's

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants