MikeMai commited on
Commit
da89fc6
·
verified ·
1 Parent(s): 0658f78

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -246,6 +246,14 @@ def gradio_upload_certificate(uploaded_file):
246
  # Always delete the existing file before saving the new one
247
  for existing_file in existing_files:
248
  os.remove(os.path.join(save_dir, existing_file))
 
 
 
 
 
 
 
 
249
 
250
  # Replace the existing file with the uploaded file
251
  new_filename = f"{safe_ship_name}_{safe_cert_name}{file_ext}"
 
246
  # Always delete the existing file before saving the new one
247
  for existing_file in existing_files:
248
  os.remove(os.path.join(save_dir, existing_file))
249
+ # Remove the file from Hugging Face as well
250
+ hf_file_path = f"{safe_ship_name}/{safe_cert_name}/{existing_file}"
251
+ api = HfApi(token=os.getenv("HF_API_KEY"))
252
+ api.delete_file(
253
+ path_in_repo=hf_file_path,
254
+ repo_id="MikeMai/Certificates_Management",
255
+ repo_type="dataset",
256
+ )
257
 
258
  # Replace the existing file with the uploaded file
259
  new_filename = f"{safe_ship_name}_{safe_cert_name}{file_ext}"