Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

283
Visualizações
Renaming / moving files using File System Access API (javascript)

I've been following this article to allow users to (semi) automatically save a client side generated XML file to a specific local folder. A third party program is watching this folder and will process its contents and output content in another file.

Problem is that it takes about 250 ms from the file is created until the content is actually written to the file using the close() method.

Sometimes the third party program will detect the file has been created and try to read its contents before its written. The program does not support adding a delay before trying to read the file content.

I've looked into writing the file to a temporary location and moving it once its closed, but this does not seem to be possible with this API. The same goes for renaming the file.

Creating / downloading the file using a normal dialog would probably work, but this requires manual steps that can be avoided using the file system access API.

Another solution would be to install a local program that can move the file from a temporary folder to the program watch folder when its closed, but I would rather avoid having to install software on the client.

Is there any other way to avoid this issue?

Thanks

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

There is now a way to rename and move files (currently implemented in Chrome 96 behind the experimental web platform features flag):

// Get references to a file and a directory.
const [file] = await showOpenFilePicker();
const directory = await showDirectoryPicker();

// Rename the file.
await file.rename('new_name');
// Move the file to a new directory.
await file.move(directory);
// Move the file to a new directory and rename it.
await file.move(directory, 'newer_name');

You can follow the spec work by subscribing to this PR.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda