'How to create a button with 'save as' functionality in react js?

I want to create a button in react js that works similar to 'save as' so that the user could select the filetype and location to be saved in the pc. I will be getting the a file from the server and want that file to be saved in a particular location. Please suggest me a solution for it.

What is the best possible way for doing this.



Solution 1:[1]

You can only use those APIs in Google Chrome and MS Edge browser.

showSaveFilePicker doc

window.showSaveFilePicker()

Ponyfills for showDirectoryPicker, showOpenFilePicker and showSaveFilePicker, with fallbacks to regular input elements

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1