阿灰 commited on
Commit
a8dcb7f
·
1 Parent(s): 5022a2d

update oss bucket

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -7,6 +7,7 @@ import json
7
  from datetime import datetime
8
  import oss2
9
  import cv2
 
10
  from pathlib import Path
11
  import decord
12
  from gradio.utils import get_cache_folder
@@ -23,12 +24,12 @@ class Examples(gr.helpers.Examples):
23
  self.create()
24
 
25
  def upload_to_oss(local_file_path, remote_file_path, expire_time=3600):
26
- remote_url = "motionshop/%s/%s" %(datetime.now().strftime("%Y%m%d"), remote_file_path)
27
  for i in range(5):
28
  try:
29
  from oss2.credentials import EnvironmentVariableCredentialsProvider
30
  auth = oss2.ProviderAuth(EnvironmentVariableCredentialsProvider())
31
- bucket = oss2.Bucket(auth, 'oss-cn-hangzhou.aliyuncs.com', 'virtualbuy-devo')
32
  bucket.put_object_from_file(key=remote_url, filename=local_file_path)
33
  break
34
  except Exception as e:
@@ -41,7 +42,7 @@ def upload_to_oss(local_file_path, remote_file_path, expire_time=3600):
41
 
42
  def get_url(filepath):
43
  filename = os.path.basename(filepath)
44
- remote_file_path = "test/%s" %filename
45
  return upload_to_oss(filepath, remote_file_path)
46
 
47
  def online_detect(filepath):
 
7
  from datetime import datetime
8
  import oss2
9
  import cv2
10
+ import uuid
11
  from pathlib import Path
12
  import decord
13
  from gradio.utils import get_cache_folder
 
24
  self.create()
25
 
26
  def upload_to_oss(local_file_path, remote_file_path, expire_time=3600):
27
+ remote_url = "motionshop2/%s/%s" %(datetime.now().strftime("%Y%m%d"), remote_file_path)
28
  for i in range(5):
29
  try:
30
  from oss2.credentials import EnvironmentVariableCredentialsProvider
31
  auth = oss2.ProviderAuth(EnvironmentVariableCredentialsProvider())
32
+ bucket = oss2.Bucket(auth, 'oss-us-east-1.aliyuncs.com', 'huggingface-motionshop')
33
  bucket.put_object_from_file(key=remote_url, filename=local_file_path)
34
  break
35
  except Exception as e:
 
42
 
43
  def get_url(filepath):
44
  filename = os.path.basename(filepath)
45
+ remote_file_path = "%s_%s" %(uuid.uuid4(), filename)
46
  return upload_to_oss(filepath, remote_file_path)
47
 
48
  def online_detect(filepath):