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

168
Views
Unable to open any file from browser

i'm using file-saver package to download files. The downloading is not the issue it seems to be the opening of any file. I console.log file from the files function logic below and get this:

File {name: '5ece9322f34d050a92546892.jpeg', lastModified: 1641918175691, lastModifiedDate: Tue Jan 11 2022 16:22:55 GMT+0000 (Greenwich Mean Time), webkitRelativePath: '', size: 156, …}
    lastModified: 1641918175691
    lastModifiedDate: Tue Jan 11 2022 16:22:55 GMT+0000 (Greenwich Mean Time)
    [[Prototype]]: Object
    name: "5ece9322f34d050a92546892.jpeg"
    size: 156
    type: ".jpeg"
    webkitRelativePath: ""
    [[Prototype]]: File

I get the following error:

The file 5ece9322f34d050a92546892.jpeg could not be opened.It may be damaged or use a file format that Preview doesn’t recognise.

My code:

import { saveAs } from 'file-saver';

  const files = ({url, fileName}) => {
    const extension = url.slice(url.lastIndexOf('.'));
      const handleDownloadDocument = (fileUrl, name, ex) => {
        const file = new File([fileUrl], name, { type: ex });
        return saveAs(file);
      };

   return(<div onClick={() => handleDownloadDocument(url, fileName, extension)}> download </div>);

};
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!