40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
import h5py, os
|
|
from floder.config import cfg
|
|
from obs import ObsClient
|
|
import obs
|
|
obsClient = ObsClient(
|
|
access_key_id='LHXJC7GIC2NNUUHHTNVI',
|
|
secret_access_key='sVWvEItrFKWPp5DxeMvX8jLFU69iXPpzkjuMX3iM',
|
|
server='https://obs.cn-east-3.myhuaweicloud.com')
|
|
bucketName = 'ieemoo-ai'
|
|
headers = obs.SetObjectMetadataHeader()
|
|
headers.cacheControl = "no-cache"
|
|
|
|
def writef(uuid, num_id, feature):
|
|
fname = os.sep.join([cfg.hFile, uuid+'.h5'])
|
|
if not os.path.exists(fname):
|
|
f = h5py.File(fname, 'w')
|
|
f[str(num_id)] = feature
|
|
else:
|
|
f = h5py.File(fname, 'a')
|
|
f[str(num_id)] = feature
|
|
#print('>>>>>>>have been write')
|
|
f.close()
|
|
|
|
def readf(uuid, num_id):
|
|
fname = os.sep.join([cfg.hFile, uuid+'.h5'])
|
|
f = h5py.File(fname, 'r')
|
|
value = f[str(num_id)][:]
|
|
f.close()
|
|
return value
|
|
|
|
def removef(uuid):
|
|
fname = os.sep.join([cfg.hFile, uuid+'.h5'])
|
|
os.remove(fname)
|
|
|
|
def uploadf(video_name, num, file_path):
|
|
time = video_name.split('-')[0]
|
|
objectkey = video_name.split('.')[0]+'_'+str(num)+'.mp4'
|
|
objectkey = 'conpurchase/'+time+'/'+objectkey
|
|
resp = obsClient.putFile(bucketName, objectkey, file_path, headers=headers)
|