Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

246
Views
Chrom Extension: onDeterminingFilenme interfers with all downloads

I'm coding an extension that downloads items with specific names. Currently, I have two types of items to download:

  • Items that have the link to the file URL, so it can be directly downloaded and its name determined by chrome.downloads.download (type A)
  • Items that don't have the link to the file URL, and had to be downloaded via a direct download link. The download process has to be initiated separately and its file name changed with chrome.downloads.onDeterminingFilename.addListener (type B)

The problem is chrome.downloads.onDeterminingFilename.addListener interfere with all downloads regardless of the parameters set. I want it only to change the filename when the type B item is downloaded.

Basic rundown of my code

chrome.downloads.download({ //type A items
      url: item.imageLink, //set linkURL
      filename: setName //set name
    });
//item will be downloaded with *setName*
chrome.downloads.onDeterminingFilename.addListener((downloadItem, suggest) => { //type B items
//item will be intercepted, its name being its original filename
  if (item != null && item.type == "B" && downloadItem.url == item.imageLink) { //check linkURL
    suggest({filename: setName, conflictAction: "uniquify"}); //item's filename will be changed to *setName*
  }  
});

Unless I remove the chrome.downloads.onDeterminingFilename completely, the file downloaded will be its original filename regardless of what type it is.

I thought of 3 possible solutions:

  1. Brute force the chrome.downloads.onDeterminingFilename, make it change the name of every item downloaded.
  • Problem: it'll mess up other downloads, including those from other extensions
  1. Remove chrome.downloads.onDeterminingFilename when it's not type B items, and add it in when it is.
  • Problem: no guarantee when it will be removed to not interfere with other items being downloaded simultaneously when it's running
  1. Figure out how to download type B items without using chrome.downloads.onDeterminingFilename
  • Problem: I've tried it, I've found nothing on converting direct download links to fileURLs, especially if the direct download link is generated uniquely

Any other suggestions or am I doing this all wrong?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!