MCPcopy Index your code
hub / github.com/stemdeckapp/stemdeck / applyFile

Function applyFile

static/js/main.js:303–328  ·  view source on GitHub ↗
(file)

Source from the content-addressed store, hash-verified

301 const MAX_UPLOAD_BYTES = 400 * 1024 * 1024; // must match server _MAX_UPLOAD_BYTES
302
303 function applyFile(file) {
304 if (!file) return;
305 const lower = file.name.toLowerCase();
306 if (!lower.endsWith(".mp3") && !lower.endsWith(".wav") && !lower.endsWith(".flac") &&
307 !lower.endsWith(".mp4") && !lower.endsWith(".m4a")) {
308 showError("Only MP3, WAV, FLAC, MP4, and M4A files are supported.");
309 return;
310 }
311 if (file.size > MAX_UPLOAD_BYTES) {
312 showError(`File is too large (${formatBytes(file.size)}). Maximum is 400 MB.`);
313 return;
314 }
315 if (fileName) fileName.textContent = file.name;
316 if (fileSize) fileSize.textContent = formatBytes(file.size);
317 filePill.classList.remove("hidden");
318 urlWrap.classList.add("has-file");
319 // Cache the File object directly on the element so job.js can always
320 // retrieve it even after the browser clears fileInput.files following
321 // a fetch() submission (known WKWebView / Chromium behaviour).
322 fileInput._file = file;
323 const dt = new DataTransfer();
324 dt.items.add(file);
325 fileInput.files = dt.files;
326 urlInput.value = "";
327 urlInput.removeAttribute("required");
328 }
329
330 function clearFile() {
331 filePill.classList.add("hidden");

Callers 1

wireFileDropFunction · 0.85

Calls 2

showErrorFunction · 0.90
formatBytesFunction · 0.85

Tested by

no test coverage detected