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

162
Views
Reactjs: where is the file path for a file uploaded in the browser?

I'm using reactjs and chrome.

I have built a webpage where I can upload an archive file and I want to do some further work on the file.

When the archive file is 7zip, I am using this library node-7z to try to extract a single file from the it.

The official documentation in the link suggests to use it like this:

// myStream is a Readable stream
const myStream = Seven.extractFull('./archive.7z', './output/dir/', {
  $progress: true
})

My code (part of it):

import sevenBin from '7zip-bin'
import Seven from 'node-7z'


const _7zOpen = async (f) => {
  console.log('_7zOpen !! ', f)
  
  // myStream is a Readable stream
  const myStream = Seven.extractFull(f.path, './output/dir/', {
    $progress: true
  })

  myStream.on('data', function (data) {
    console.log(data)
  })

  myStream.on('progress', function (progress) {
    console.log(progress)
  })

}

where the input f is a file object:

_7zOpen !!  
File {path: 'CE027001-120011101924-T100.7z', 
name: 'CE027001-120011101924-T100.7z', 
lastModified: 1599377977254, 
lastModifiedDate: Sun Sep 06 2020 16:39:37 GMT+0900, webkitRelativePath: '', …}
lastModified: 1599377977254
lastModifiedDate: Sun Sep 06 2020 16:39:37 GMT+0900 {}
name: "CE027001-120011101924-T100.7z"
path: "CE027001-120011101924-T100.7z"
size: 75602083
type: "application/x-7z-compressed"
webkitRelativePath: ""
[[Prototype]]: File

It gives an error:

Unhandled Rejection (TypeError): spawn is not a function
▼ 3 stack frames were expanded.
run
node_modules/node-7z/src/lifecycle.js:74
(anonymous function)
node_modules/node-7z/src/main.js:55
extractFull
node_modules/node-7z/src/commands.js:27
▲ 3 stack frames were expanded.

_7zOpen
src/components/shared/utils/compressedFileHandler.js:56
  53 | 
  54 | 
  55 | const pathTo7zip = sevenBin.path7za;
> 56 | const seven = Seven.extractFull(f.path, './output/dir/', {
     | ^  57 |   $bin: pathTo7zip
  58 | });
  59 | 


I tried another way:

const _7zOpen = async (f) => {
  console.log('_7zOpen !! ', f)
  
  const pathTo7zip = sevenBin.path7za;
  const seven = Seven.extractFull(f.path, './output/dir/', {
    $bin: pathTo7zip
  });

}

which gives the same error message when the file is uploaded.

It could be that the f.path is not valid. How can I find the correct path to feed to the function?

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!