(uploadDirectory = false)
| 125 | } |
| 126 | } |
| 127 | function onClickUploadFile(uploadDirectory = false) { |
| 128 | const fileInput = document.createElement('input'); |
| 129 | fileInput.type = 'file'; |
| 130 | fileInput.multiple = true; |
| 131 | if (uploadDirectory) { |
| 132 | fileInput.webkitdirectory = true; |
| 133 | fileInput.mozdirectory = true; |
| 134 | fileInput.directory = true; |
| 135 | } |
| 136 | fileInput.click(); |
| 137 | fileInput.onchange = async event => { |
| 138 | const chosenFilesList = event.target?.files; |
| 139 | const chosenFiles = Array.from(chosenFilesList); |
| 140 | isUploading.value = true; |
| 141 | uploadProgress.value = ''; |
| 142 | for (const chosenFile of chosenFiles) { |
| 143 | if (!chosenFile) { |
| 144 | continue; |
| 145 | } |
| 146 | areNewOptionsOpen.value = false; |
| 147 | let fileParentPath = path.value; |
| 148 | if (chosenFile.webkitRelativePath) { |
| 149 | const directoryPath = chosenFile.webkitRelativePath.replace(chosenFile.name, ''); |
| 150 | fileParentPath = `${path.value}${directoryPath}`; |
| 151 | } |
| 152 | uploadProgress.value = ''; |
| 153 | try { |
| 154 | if (chosenFile.size >= CHUNK_SIZE_BYTES) { |
| 155 | await uploadFileChunked(chosenFile, fileParentPath); |
| 156 | } else { |
| 157 | await uploadFileSingle(chosenFile, fileParentPath); |
| 158 | } |
| 159 | } catch (error) { |
| 160 | console.error(error); |
| 161 | } |
| 162 | } |
| 163 | isUploading.value = false; |
| 164 | }; |
| 165 | } |
| 166 | function onClickCreateDirectory() { |
| 167 | if (isNewDirectoryModalOpen.value) { |
| 168 | isNewDirectoryModalOpen.value = false; |
no test coverage detected