vericudebuget commited on
Commit
1187796
·
verified ·
1 Parent(s): 4478b28

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  from huggingface_hub import HfApi
3
  import os
 
4
 
5
  # Initialize the Hugging Face API with the token
6
  api = HfApi(token=os.getenv("HF_API_TOKEN"))
@@ -9,10 +10,10 @@ def upload_video(video):
9
  # Save the uploaded video to a temporary file
10
  video_path = os.path.join("temp", video.name)
11
 
12
- # Write the file from the binary content
13
  with open(video_path, "wb") as f:
14
- f.write(video.read_bytes()) # Use read_bytes() instead of read()
15
-
16
  # Upload the video to Hugging Face
17
  api.upload_file(
18
  path_or_fileobj=video_path,
 
1
  import gradio as gr
2
  from huggingface_hub import HfApi
3
  import os
4
+ import shutil
5
 
6
  # Initialize the Hugging Face API with the token
7
  api = HfApi(token=os.getenv("HF_API_TOKEN"))
 
10
  # Save the uploaded video to a temporary file
11
  video_path = os.path.join("temp", video.name)
12
 
13
+ # Write the file from the uploaded content
14
  with open(video_path, "wb") as f:
15
+ shutil.copyfileobj(video, f) # Use shutil.copyfileobj to write the file
16
+
17
  # Upload the video to Hugging Face
18
  api.upload_file(
19
  path_or_fileobj=video_path,