Using certain characters in the filename argument to the function chrome.downloads.download leads to an "Invalid filename" error, when starting the download. I can't find any information in the documentation and replacing for example : with %3A or : ; doesn't work.
The problematic characters are:
: " ? ~ < > * |
Here is an example you can use in the background page console from any extension with the downloads permission.
chrome.downloads.download(
{url: ".webm",
filename: "title:subtitle.webm"},
function (downloadId) {
if (downloadId===undefined)
console.log(chrome.runtime.lastError);
else
console.log("Ok");
});
Is there a way to use these problematic characters?
Edit: Is there a list for the characters chrome.downloads.download doesn't support?
Edit 2: To put it another way. The user can manually download a file in Chrome (Linux) and, in the download dialog, name it:
title:subtitle.extension
I would like to do the same in my extension.
This filename is just an example, the filenames get generated automatically depending on the webpage and some user generated rules.
Using certain characters in the filename argument to the function chrome.downloads.download leads to an "Invalid filename" error, when starting the download. I can't find any information in the documentation and replacing for example : with %3A or : ; doesn't work.
The problematic characters are:
: " ? ~ < > * |
Here is an example you can use in the background page console from any extension with the downloads permission.
chrome.downloads.download(
{url: "http://i.imgur./3cWNMt3.webm",
filename: "title:subtitle.webm"},
function (downloadId) {
if (downloadId===undefined)
console.log(chrome.runtime.lastError);
else
console.log("Ok");
});
Is there a way to use these problematic characters?
Edit: Is there a list for the characters chrome.downloads.download doesn't support?
Edit 2: To put it another way. The user can manually download a file in Chrome (Linux) and, in the download dialog, name it:
title:subtitle.extension
I would like to do the same in my extension.
This filename is just an example, the filenames get generated automatically depending on the webpage and some user generated rules.
Is there a way to use these problematic characters?
No. That would be an invalid filename.
What exactly is invalid varies by OS. Here's a full ruleset for Windows.
A mon strategy is to replace the characters with something allowed; for example, _
See also this question.