From 4374d4cc554a25398d86b1044698608f1c9d32d4 Mon Sep 17 00:00:00 2001
From: Muhammad Abdullah Shahid
<108458621+abdollahShahid@users.noreply.github.com>
Date: Wed, 31 Dec 2025 11:55:03 +0500
Subject: [PATCH 1/4] docs: clarify folders are not supported for upload
Signed-off-by: Muhammad Abdullah Shahid <108458621+abdollahShahid@users.noreply.github.com>
---
docs/inputs.rst | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/docs/inputs.rst b/docs/inputs.rst
index d87acd2203..8949534162 100644
--- a/docs/inputs.rst
+++ b/docs/inputs.rst
@@ -16,12 +16,16 @@ Supported file types include archives (e.g., ``.tar``, ``.zip``, ``.tar.gz``),
individual source files, pre-built packages, and **SBOMs** (SPDX or CycloneDX in
JSON format).
+.. note::
+
+ Uploading folders/directories is not supported. If you need to upload a folder,
+ create an archive (e.g., ``.zip`` or ``.tar.gz``) and upload the archive instead.
+
When uploading through the Web UI, navigate to your project and use the upload
interface in the "Inputs" panel.
For REST API uploads, refer to the :ref:`rest_api` documentation for endpoint details.
-.. _inputs_download_url:
Download URL
------------
From 5dcedfc25cb97b4577fa03389f031c03466202ff Mon Sep 17 00:00:00 2001
From: Muhammad Abdullah Shahid
<108458621+abdollahShahid@users.noreply.github.com>
Date: Wed, 31 Dec 2025 12:05:23 +0500
Subject: [PATCH 2/4] ui: show warning when a folder is dropped for upload
Signed-off-by: Muhammad Abdullah Shahid <108458621+abdollahShahid@users.noreply.github.com>
---
scancodeio/static/add-inputs.js | 60 +++++++++++++++++++++++++--------
1 file changed, 46 insertions(+), 14 deletions(-)
diff --git a/scancodeio/static/add-inputs.js b/scancodeio/static/add-inputs.js
index 0a99d1233a..2565e788b9 100644
--- a/scancodeio/static/add-inputs.js
+++ b/scancodeio/static/add-inputs.js
@@ -24,6 +24,9 @@ const fileInput = document.querySelector("#id_input_files");
let selectedFiles = []; // Store selected files
fileInput.onchange = updateFiles;
+// Handle drag and drop events
+const inputFilesBox = document.querySelector("#input_files_box");
+
// Update the list of files to be uploaded in the UI
function updateFiles() {
if (fileInput.files.length > 0) {
@@ -33,14 +36,16 @@ function updateFiles() {
// Update the selectedFiles array
const newFiles = Array.from(fileInput.files);
// Create a Set to track unique file names
- const uniqueFileNames = new Set(selectedFiles.map(file => file.name));
+ const uniqueFileNames = new Set(selectedFiles.map((file) => file.name));
// Filter out files with the same name
- const filteredNewFiles = newFiles.filter(file => !uniqueFileNames.has(file.name));
+ const filteredNewFiles = newFiles.filter(
+ (file) => !uniqueFileNames.has(file.name)
+ );
// Concatenate the unique files to the existing selectedFiles array
selectedFiles = selectedFiles.concat(filteredNewFiles);
for (let file of selectedFiles) {
- const fileNameWithoutSpaces = file.name.replace(/\s/g, '');
+ const fileNameWithoutSpaces = file.name.replace(/\s/g, "");
fileName.innerHTML += `
${file.name}
@@ -49,13 +54,15 @@ function updateFiles() {
`;
- document.getElementById("file-delete-btn-"+ fileNameWithoutSpaces).addEventListener("click", function(event){
- disableEvent(event);
- removeFile(fileNameWithoutSpaces);
- if(selectedFiles.length == 0){
- fileName.innerHTML ="No files selected"
- }
- });
+ document
+ .getElementById("file-delete-btn-" + fileNameWithoutSpaces)
+ .addEventListener("click", function (event) {
+ disableEvent(event);
+ removeFile(fileNameWithoutSpaces);
+ if (selectedFiles.length == 0) {
+ fileName.innerHTML = "No files selected";
+ }
+ });
}
}
}
@@ -67,8 +74,8 @@ function disableEvent(event) {
}
function removeFile(fileName) {
- selectedFiles = selectedFiles.filter(file => {
- const fileNameWithoutSpaces = file.name.replace(/\s/g, '');
+ selectedFiles = selectedFiles.filter((file) => {
+ const fileNameWithoutSpaces = file.name.replace(/\s/g, "");
return fileNameWithoutSpaces !== fileName;
});
@@ -85,8 +92,35 @@ function removeFile(fileName) {
fileInput.files = dataTransfer.files;
}
+function showFolderUploadNotSupportedMessage() {
+ let notice = document.querySelector("#folder-upload-notice");
+ if (!notice) {
+ notice = document.createElement("div");
+ notice.id = "folder-upload-notice";
+ notice.className = "notification is-warning is-light mt-2";
+ notice.innerHTML = `
+ Folders are not supported.
+ Please upload a .zip or .tar.gz archive instead.
+ `;
+ inputFilesBox.insertAdjacentElement("afterend", notice);
+ }
+}
+
function dropHandler(event) {
disableEvent(event);
+
+ // Detect folder drops (directories are not supported)
+ const items = event.dataTransfer.items;
+ if (items) {
+ for (const item of items) {
+ const entry = item.webkitGetAsEntry?.();
+ if (entry && entry.isDirectory) {
+ showFolderUploadNotSupportedMessage();
+ return;
+ }
+ }
+ }
+
const droppedFiles = event.dataTransfer.files;
const updatedFilesSet = new Set(Array.from(fileInput.files));
@@ -106,8 +140,6 @@ function dropHandler(event) {
updateFiles();
}
-// Handle drag and drop events
-const inputFilesBox = document.querySelector("#input_files_box");
inputFilesBox.addEventListener("dragenter", disableEvent);
inputFilesBox.addEventListener("dragover", disableEvent);
inputFilesBox.addEventListener("drop", dropHandler);
From 4203bd9644e0e3cac5052565eb3478ff87167263 Mon Sep 17 00:00:00 2001
From: Muhammad Abdullah Shahid
<108458621+abdollahShahid@users.noreply.github.com>
Date: Wed, 31 Dec 2025 12:12:27 +0500
Subject: [PATCH 3/4] Update docs/inputs.rst
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Muhammad Abdullah Shahid <108458621+abdollahShahid@users.noreply.github.com>
---
docs/inputs.rst | 1 +
1 file changed, 1 insertion(+)
diff --git a/docs/inputs.rst b/docs/inputs.rst
index 8949534162..fcbd02ff6f 100644
--- a/docs/inputs.rst
+++ b/docs/inputs.rst
@@ -26,6 +26,7 @@ interface in the "Inputs" panel.
For REST API uploads, refer to the :ref:`rest_api` documentation for endpoint details.
+.. _inputs_download_url:
Download URL
------------
From 1433bffb55994d92d98b8d3b6a82117066b2d6ae Mon Sep 17 00:00:00 2001
From: Muhammad Abdullah Shahid
<108458621+abdollahShahid@users.noreply.github.com>
Date: Wed, 31 Dec 2025 12:12:35 +0500
Subject: [PATCH 4/4] Update scancodeio/static/add-inputs.js
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Muhammad Abdullah Shahid <108458621+abdollahShahid@users.noreply.github.com>
---
scancodeio/static/add-inputs.js | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/scancodeio/static/add-inputs.js b/scancodeio/static/add-inputs.js
index 2565e788b9..29654faaeb 100644
--- a/scancodeio/static/add-inputs.js
+++ b/scancodeio/static/add-inputs.js
@@ -109,19 +109,36 @@ function showFolderUploadNotSupportedMessage() {
function dropHandler(event) {
disableEvent(event);
- // Detect folder drops (directories are not supported)
const items = event.dataTransfer.items;
- if (items) {
+ let droppedFiles = [];
+ let hasDirectory = false;
+
+ if (items && items.length > 0) {
+ // Build a list of files from the dropped items, skipping directories
for (const item of items) {
const entry = item.webkitGetAsEntry?.();
if (entry && entry.isDirectory) {
- showFolderUploadNotSupportedMessage();
- return;
+ hasDirectory = true;
+ continue;
+ }
+ const file = item.getAsFile?.();
+ if (file) {
+ droppedFiles.push(file);
}
}
+ } else {
+ // Fallback when items are not available
+ droppedFiles = Array.from(event.dataTransfer.files || []);
}
- const droppedFiles = event.dataTransfer.files;
+ if (hasDirectory) {
+ showFolderUploadNotSupportedMessage();
+ }
+
+ // If there are no files at all (e.g. only folders were dropped), do nothing further
+ if (droppedFiles.length === 0) {
+ return;
+ }
const updatedFilesSet = new Set(Array.from(fileInput.files));
for (let file of droppedFiles) {