Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -54,22 +54,17 @@ def save_uploaded_file(uploaded_file):
|
|
54 |
if uploaded_file is None:
|
55 |
return None # Handle cases where no file was uploaded
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
63 |
|
64 |
-
with open(file_path, "wb") as f:
|
65 |
-
# Attempt to read from the file object if possible
|
66 |
-
file_content = uploaded_file.file.read()
|
67 |
-
f.write(file_content) # Save file content to disk
|
68 |
-
return file_path
|
69 |
-
else:
|
70 |
-
# If expected attributes are not found, print available attributes
|
71 |
-
print(f"Available attributes: {dir(uploaded_file)}") # Debug: List attributes
|
72 |
-
return None
|
73 |
|
74 |
def display_results(video_url, video_file, description):
|
75 |
"""Process video from URL or file upload and return the results."""
|
|
|
54 |
if uploaded_file is None:
|
55 |
return None # Handle cases where no file was uploaded
|
56 |
|
57 |
+
print(f"File name: {uploaded_file.name}") # Debug: Print file name
|
58 |
+
upload_dir = "uploaded_videos"
|
59 |
+
os.makedirs(upload_dir, exist_ok=True)
|
60 |
+
file_path = os.path.join(upload_dir, uploaded_file.name)
|
61 |
+
|
62 |
+
# Since the file is received as a string, write it directly
|
63 |
+
with open(file_path, "wb") as f:
|
64 |
+
f.write(uploaded_file.encode('utf-8')) # Encode to bytes and write if necessary
|
65 |
+
|
66 |
+
return file_path
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
def display_results(video_url, video_file, description):
|
70 |
"""Process video from URL or file upload and return the results."""
|