update
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
from obs import ObsClient
|
||||
import obs
|
||||
from datetime import datetime
|
||||
#from config import cfg
|
||||
from utils.config import cfg
|
||||
@ -12,6 +13,8 @@ obsClient = ObsClient(
|
||||
server='https://obs.cn-east-3.myhuaweicloud.com'
|
||||
)
|
||||
bucketName = 'ieemoo-ai'
|
||||
headers = obs.SetObjectMetadataHeader()
|
||||
headers.cacheControl = "no-cache"
|
||||
|
||||
def AddObs(file_path, status):
|
||||
with lock:
|
||||
@ -52,7 +55,7 @@ def addobs(file_path, status): #save videos
|
||||
time = os.path.basename(file_path).split('-')[0]
|
||||
if objectkey.split('.')[-1] in ['avi','mp4']:
|
||||
objectkey = 'videos/'+time+'/'+status+'/'+status+'_'+objectkey
|
||||
resp = obsClient.putFile(bucketName, objectkey, file_path)
|
||||
resp = obsClient.putFile(bucketName, objectkey, file_path, hearders=headers)
|
||||
#os.remove(file_path)
|
||||
|
||||
def updateAgain():
|
||||
@ -70,7 +73,7 @@ def updateAgain():
|
||||
time = os.path.basename(file_path).split('-')[0]
|
||||
if objectkey.split('.')[-1] in ['avi','mp4']:
|
||||
objectkey = 'videos/'+time+'/'+status+'/'+status+'_'+objectkey
|
||||
resp = obsClient.putFile(bucketName, objectkey, file_path)
|
||||
resp = obsClient.putFile(bucketName, objectkey, file_path, hearders=headers)
|
||||
os.remove(file_path)
|
||||
except Exception as e:
|
||||
pass
|
||||
@ -83,14 +86,14 @@ def Addimg(uuid_barcode):
|
||||
file_path = os.sep.join([cfg.Tempimg, '3_'+uuid_barcode+'.jpg'])
|
||||
if not os.path.exists(file_path):
|
||||
file_path = os.sep.join([cfg.Tempimg, 'ex_'+uuid_barcode+'.jpg'])
|
||||
resp = obsClient.putFile(bucketName, objectkey, file_path)
|
||||
resp = obsClient.putFile(bucketName, objectkey, file_path, hearders=headers)
|
||||
|
||||
def Addimg_content(uuid_barcode, context):
|
||||
success, encoded_image = cv2.imencode(".jpg",context)
|
||||
context = encoded_image.tobytes()
|
||||
time = uuid_barcode.split('-')[0]
|
||||
objectkey = 'imgs/'+time+'/'+uuid_barcode+'.jpg'
|
||||
resp = obsClient.putContent(bucketName, objectkey, context)
|
||||
resp = obsClient.putContent(bucketName, objectkey, context, hearders=headers)
|
||||
|
||||
if __name__ == '__main__':
|
||||
import cv2
|
||||
|
Reference in New Issue
Block a user