Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No .vv file downloaded #1952

Open
aaaaadrien opened this issue Dec 19, 2024 · 2 comments
Open

No .vv file downloaded #1952

aaaaadrien opened this issue Dec 19, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@aaaaadrien
Copy link

Explain what happens

  1. Open cockpit
  2. Go to Virtual Machines tab
  3. Start a VM
  4. Clic on Launch remote viewer

The file has no extension.
On Google Chrome : "download"
On Firefox : "FHfpQ1UH"
On Vivaldi : "file"

With No extension, open the file directly in the browser (to not download it) didn't work because the association is with extension.

Version of Cockpit

cockpit-machines 325

Where is the problem in Cockpit?

Unknown or not applicable

Server operating system

Fedora

Server operating system version

41

What browsers are you using?

Firefox, Chrome, Other

System log

No response

@aaaaadrien aaaaadrien added the bug Something isn't working label Dec 19, 2024
@martinpitt martinpitt transferred this issue from cockpit-project/cockpit Dec 20, 2024
@martinpitt martinpitt changed the title cockpit-machines : No .vv file downloaded No .vv file downloaded Dec 20, 2024
@garrett
Copy link
Member

garrett commented Jan 15, 2025

This is a regression; .vv used to be added at the end of the file at some point in time. It was a while ago when this worked though.

The fix is to use a URL like this:

<a href="DATA-URI" download="filename.vv" class="pf-v5-c-button">Button label</a>

We could also do this via JavaScript with something like this vanilla JavaScript instead (which basically accepts an object dynamically wraps up the above HTML and clicks it):

const downloadVirtViewerFile = (content, filename = 'virt-viewer-launcher.vv') => {
  // Create a data URL with the content and filename
  const dataURI = URL.createObjectURL(new File(content, filename, { type: 'text/plain' }));

  // Create an anchor (link), assign the content and filename, then click it
  Object.assign(document.createElement('a'), { href: dataURI, download: filename }).click();

  // Release the memory
  URL.revokeObjectURL(dataURI);
};

(Perhaps there's some React stuff that can do some of these things automatically; I don't know.)

@garrett
Copy link
Member

garrett commented Jan 15, 2025

Oh, BTW: the mimetype might need to be application/x-virt-viewer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants