function chooseFile(type) {
  return new Promise((resolve, reject) => {
    let fileId = type + new Date().getTime();
    let inputObj = document.createElement("input");
    inputObj.setAttribute("id", fileId);
    inputObj.setAttribute("type", "file");
    inputObj.setAttribute("style", "visibility:hidden");
    document.body.appendChild(inputObj);
    inputObj.addEventListener("change", (e) => {
      resolve(document.getElementById(fileId).files[0]);
    });
    inputObj.click();
  });
}

export { chooseFile };
