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

217
Views
Node.js: Get original object name

I modelled a surface in a CAD program, gave it a certain name (e.g. surface1) and locally saved this surface with a specific name on my desktop (e.g. filename = surf or apple or ...).

Now I write an application where I want to upload/post a larger number of such surf-files on a website. Via a SaveFileDialog I can choose the required files and upload them.

The files are imported as follows: var filename = dialog.showOpenDialog(options);

The files are served for the public webserver as follows:

[...]
.then(async function (data) {
            token = data.id_token;
            let formData = new FormData;
            formData.append('file', new Blob([fs.readFileSync(filename.toString())]), filename.toString().split("/").pop());
            let response = await fetch(url, {
                method: 'POST',
                headers: {
                    "Accept": "application/json, text/plain, */*",
                    "Authorization": " Bearer " + token
                },
                body: formData
            });
            return response;

The problem: For some filter routine I need the original object or surface name, like it was chosen in the CAD program (surface1). When I want to work with the variable filename, the SaveFileDialog only seems to take the local file path with the freely chosen desktop name (surf). The original object name (surface1) seems to be overwritten for a further use in my application.
But when I upload the file manually on the website (Frontend), the user interface shows me the original object or surface name like in the CAD program (surface1).

(Interesting fact: The code above also results in a successful post/upload with the original object name on the user interface (surface1). But when I try to pull the name from filename.toString().split("/").pop() I get the desktop name (surf) again.)

Where could the webserver get the original object name from? How can I get the original name of the object (surface1)?

Don't hesitate to ask for more infos if I was to restrained. The framework I use is Electron. Thank you!

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!