DetectControllerV2.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. import json
  2. import logging
  3. import os
  4. import threading
  5. import time
  6. import apns2
  7. import boto3
  8. import botocore
  9. import jpush as jpush
  10. from botocore import client
  11. from django.http import JsonResponse
  12. from django.views.generic.base import View
  13. from pyfcm import FCMNotification
  14. from AnsjerPush.config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
  15. from AnsjerPush.config import JPUSH_CONFIG, FCM_CONFIG, APNS_CONFIG, BASE_DIR, APNS_MODE
  16. from Model.models import UidPushModel, SysMsgModel
  17. from Object.ETkObject import ETkObject
  18. from Object.RedisObject import RedisObject
  19. from Object.UidTokenObject import UidTokenObject
  20. from Object.utils import LocalDateTimeUtil
  21. from Service.CommonService import CommonService
  22. from Service.EquipmentInfoService import EquipmentInfoService
  23. from Service.GatewayService import GatewayPushService
  24. # 移动侦测V2接口
  25. class NotificationV2View(View):
  26. def get(self, request, *args, **kwargs):
  27. request.encoding = 'utf-8'
  28. return self.validation(request.GET)
  29. def post(self, request, *args, **kwargs):
  30. request.encoding = 'utf-8'
  31. return self.validation(request.POST)
  32. def validation(self, request_dict):
  33. logger = logging.getLogger('info')
  34. logger.info("移动侦测V2接口参数:{}".format(request_dict))
  35. uidToken = request_dict.get('uidToken', None)
  36. etk = request_dict.get('etk', None)
  37. channel = request_dict.get('channel', '1')
  38. n_time = request_dict.get('n_time', None)
  39. event_type = request_dict.get('event_type', None)
  40. is_st = request_dict.get('is_st', None)
  41. region = request_dict.get('region', None)
  42. electricity = request_dict.get('electricity', '')
  43. if not all([channel, n_time]):
  44. return JsonResponse(status=200, data={
  45. 'code': 444,
  46. 'msg': 'param is wrong'})
  47. if not region or not is_st:
  48. return JsonResponse(status=200, data={'code': 404, 'msg': 'no region or is_st'})
  49. try:
  50. is_st = int(is_st)
  51. region = int(region)
  52. # 解密获取uid
  53. if etk:
  54. eto = ETkObject(etk)
  55. uid = eto.uid
  56. else:
  57. uto = UidTokenObject(uidToken)
  58. uid = uto.UID
  59. # uid = request_dict.get('uid', None) # 调试
  60. # 判断uid长度
  61. if len(uid) != 20 and len(uid) != 14:
  62. return JsonResponse(status=200, data={'code': 404, 'msg': 'wrong uid'})
  63. logger.info('调用推送接口的uid:{}'.format(uid))
  64. pkey = '{uid}_{channel}_{event_type}_ptl'.format(uid=uid, channel=channel, event_type=event_type)
  65. ykey = '{uid}_redis_qs'.format(uid=uid)
  66. is_sys_msg = self.is_sys_msg(int(event_type))
  67. if is_sys_msg:
  68. dkey = '{uid}_{channel}_{event_type}_flag'.format(uid=uid, channel=channel, event_type=event_type)
  69. else:
  70. dkey = '{uid}_{channel}_flag'.format(uid=uid, channel=channel)
  71. redisObj = RedisObject(db=6)
  72. have_ykey = redisObj.get_data(key=ykey) # uid_set 数据库缓存
  73. have_pkey = redisObj.get_data(key=pkey) # 一分钟限制key
  74. have_dkey = redisObj.get_data(key=dkey) # 推送消息时间间隔
  75. logger.info('ykey:{}, pkey: {}, dkey: {},'.format(have_ykey, have_pkey, have_dkey))
  76. # 一分钟内不推送
  77. if have_pkey:
  78. return JsonResponse(status=200, data={'code': 0, 'msg': 'Push again in one minute'})
  79. redisObj.set_data(key=pkey, val=1, expire=60)
  80. # 查询推送数据
  81. uid_push_qs = UidPushModel.objects.filter(uid_set__uid=uid, uid_set__detect_status=1). \
  82. values('token_val', 'app_type', 'appBundleId', 'm_code', 'push_type', 'userID_id', 'userID__NickName',
  83. 'lang', 'm_code', 'tz', 'uid_set__nickname', 'uid_set__detect_interval', 'uid_set__detect_group',
  84. 'uid_set__channel', 'uid_set__ai_type')
  85. if not uid_push_qs.exists():
  86. logger.info('uid_push 数据不存在')
  87. return JsonResponse(status=200, data={'code': 176, 'msg': 'no uid_push data'})
  88. ai_type = uid_push_qs.first()['uid_set__ai_type']
  89. event_type = self.get_combo_msg_type(ai_type, event_type)
  90. redis_list = []
  91. for qs in uid_push_qs:
  92. redis_list.append(qs)
  93. # 修改redis数据,并设置过期时间为10分钟
  94. redisObj.set_data(key=ykey, val=str(redis_list), expire=600)
  95. nickname = redis_list[0]['uid_set__nickname']
  96. detect_interval = redis_list[0]['uid_set__detect_interval']
  97. detect_group = redis_list[0]['uid_set__detect_group']
  98. if not nickname:
  99. nickname = uid
  100. if not have_dkey:
  101. # 设置推送消息的时间间隔
  102. if detect_group == '0' or detect_group == '':
  103. redisObj.set_data(key=dkey, val=1, expire=detect_interval)
  104. else:
  105. detect_group_list = detect_group.split(',')
  106. if event_type in detect_group_list:
  107. if detect_interval < 60:
  108. detect_interval = 60
  109. redisObj.set_data(key=dkey, val=1, expire=detect_interval)
  110. if is_st == 1 or is_st == 3: # 使用aws s3
  111. aws_s3_client = s3_client(region=region)
  112. bucket = 'foreignpush' if region == 1 else 'push'
  113. kwag_args = {
  114. 'uid': uid,
  115. 'channel': channel,
  116. 'event_type': event_type,
  117. 'n_time': n_time,
  118. }
  119. sys_msg_list = []
  120. userID_ids = []
  121. do_apns_code = ''
  122. do_fcm_code = ''
  123. do_jpush_code = ''
  124. logger.info('进入手机推送------')
  125. logger.info('uid={}'.format(uid))
  126. logger.info(redis_list)
  127. new_device_info_list = []
  128. local_date_time = ''
  129. for up in redis_list:
  130. push_type = up['push_type']
  131. appBundleId = up['appBundleId']
  132. token_val = up['token_val']
  133. lang = up['lang']
  134. tz = up['tz']
  135. if tz is None or tz == '':
  136. tz = 0
  137. # 发送标题
  138. msg_title = self.get_msg_title(appBundleId=appBundleId, nickname=nickname)
  139. # 发送内容
  140. msg_text = self.get_msg_text(channel=channel, n_time=n_time, lang=lang, tz=tz,
  141. event_type=event_type, electricity=electricity)
  142. kwag_args['appBundleId'] = appBundleId
  143. kwag_args['token_val'] = token_val
  144. kwag_args['msg_title'] = msg_title
  145. kwag_args['msg_text'] = msg_text
  146. logger.info('推送要的数据: {}'.format(kwag_args))
  147. local_date_time = CommonService.get_now_time_str(n_time=n_time, tz=tz, lang='cn')
  148. logger.info('<<<<<根据时区计算后日期={},时区={}'.format(local_date_time, tz))
  149. local_date_time = local_date_time[0:10]
  150. logger.info('<<<<<切片后的日期={}'.format(local_date_time))
  151. # 以下是存库
  152. userID_id = up["userID_id"]
  153. if userID_id not in userID_ids:
  154. now_time = int(time.time())
  155. if is_sys_msg:
  156. sys_msg_text = self.get_msg_text(channel=channel, n_time=n_time, lang=lang, tz=tz,
  157. event_type=event_type, electricity=electricity, is_sys=1)
  158. sys_msg_list.append(SysMsgModel(
  159. userID_id=userID_id,
  160. msg=sys_msg_text,
  161. addTime=now_time,
  162. updTime=now_time,
  163. uid=uid,
  164. eventType=event_type))
  165. else:
  166. # start 根据设备侦测时间为准进行分表存储数据
  167. logger.info('分表存数据start------')
  168. new_device_info_list.append(EquipmentInfoService.get_equipment_info_obj(
  169. local_date_time,
  170. device_user_id=userID_id,
  171. event_time=n_time,
  172. event_type=event_type,
  173. device_uid=uid,
  174. device_nick_name=nickname,
  175. channel=channel,
  176. alarm='Motion \tChannel:{channel}'.format(channel=channel),
  177. is_st=is_st,
  178. receive_time=n_time,
  179. add_time=now_time,
  180. storage_location=2,
  181. border_coords='',
  182. ))
  183. # end
  184. userID_ids.append(userID_id)
  185. try:
  186. # 推送消息
  187. if not have_dkey:
  188. logger.info('准备推送:{}, {}'.format(uid, request_dict))
  189. if (is_st == 1 or is_st == 3) and (push_type == 0 or push_type == 1): # 推送显示图片
  190. if is_st == 1:
  191. key = '{}/{}/{}.jpeg'.format(uid, channel, n_time)
  192. else:
  193. key = '{}/{}/{}_0.jpeg'.format(uid, channel, n_time)
  194. push_thread = threading.Thread(target=self.push_thread_test, args=(
  195. push_type, aws_s3_client, bucket, key, uid, appBundleId, token_val, event_type, n_time,
  196. msg_title, msg_text, channel))
  197. push_thread.start()
  198. else:
  199. if push_type == 0: # ios apns
  200. do_apns_code = self.do_apns(**kwag_args)
  201. elif push_type == 1: # android gcm
  202. do_fcm_code = self.do_fcm(**kwag_args)
  203. elif push_type == 2: # android jpush
  204. do_jpush_code = self.do_jpush(**kwag_args)
  205. except Exception as e:
  206. logger.info(
  207. "errLine={errLine}, errMsg={errMsg}".format(errLine=e.__traceback__.tb_lineno, errMsg=repr(e)))
  208. continue
  209. if is_sys_msg:
  210. SysMsgModel.objects.bulk_create(sys_msg_list)
  211. else:
  212. # new 分表批量存储 设备信息
  213. if new_device_info_list and len(new_device_info_list) > 0:
  214. # 根据日期获得星期几
  215. week = LocalDateTimeUtil.date_to_week(local_date_time)
  216. EquipmentInfoService.equipment_info_bulk_create(week, new_device_info_list)
  217. logger.info('设备信息分表批量保存end------')
  218. if is_st == 0 or is_st == 2:
  219. for up in redis_list:
  220. if up['push_type'] == 0: # ios apns
  221. up['do_apns_code'] = do_apns_code
  222. elif up['push_type'] == 1: # android gcm
  223. up['do_fcm_code'] = do_fcm_code
  224. elif up['push_type'] == 2: # android jpush
  225. up['do_jpush_code'] = do_jpush_code
  226. del up['push_type']
  227. del up['userID_id']
  228. del up['userID__NickName']
  229. del up['lang']
  230. del up['tz']
  231. del up['uid_set__nickname']
  232. del up['uid_set__detect_interval']
  233. del up['uid_set__detect_group']
  234. return JsonResponse(status=200, data={'code': 0, 'msg': 'success 0 or 2', 're_list': redis_list})
  235. elif is_st == 1:
  236. thumbspng = '{uid}/{channel}/{filename}.jpeg'.format(uid=uid, channel=channel, filename=n_time)
  237. Params = {'Key': thumbspng}
  238. if region == 2: # 2:国内
  239. Params['Bucket'] = 'push'
  240. else: # 1:国外
  241. Params['Bucket'] = 'foreignpush'
  242. response_url = generate_s3_url(aws_s3_client, Params)
  243. for up in redis_list:
  244. up['do_apns_code'] = do_apns_code
  245. up['do_fcm_code'] = do_fcm_code
  246. up['do_jpush_code'] = do_jpush_code
  247. del up['push_type']
  248. del up['userID_id']
  249. del up['userID__NickName']
  250. del up['lang']
  251. del up['tz']
  252. del up['uid_set__nickname']
  253. del up['uid_set__detect_interval']
  254. del up['uid_set__detect_group']
  255. res_data = {'code': 0, 'img_push': response_url, 'msg': 'success'}
  256. return JsonResponse(status=200, data=res_data)
  257. elif is_st == 3:
  258. img_url_list = []
  259. if region == 2: # 2:国内
  260. Params = {'Bucket': 'push'}
  261. else: # 1:国外
  262. Params = {'Bucket': 'foreignpush'}
  263. for i in range(is_st):
  264. thumbspng = '{uid}/{channel}/{filename}_{st}.jpeg'. \
  265. format(uid=uid, channel=channel, filename=n_time, st=i)
  266. Params['Key'] = thumbspng
  267. response_url = generate_s3_url(aws_s3_client, Params)
  268. img_url_list.append(response_url)
  269. for up in redis_list:
  270. up['do_apns_code'] = do_apns_code
  271. up['do_fcm_code'] = do_fcm_code
  272. up['do_jpush_code'] = do_jpush_code
  273. del up['push_type']
  274. del up['userID_id']
  275. del up['userID__NickName']
  276. del up['lang']
  277. del up['tz']
  278. del up['uid_set__nickname']
  279. del up['uid_set__detect_interval']
  280. del up['uid_set__detect_group']
  281. res_data = {'code': 0, 'img_url_list': img_url_list, 'msg': 'success 3'}
  282. return JsonResponse(status=200, data=res_data)
  283. except Exception as e:
  284. logger.info('移动侦测接口异常: {}'.format(e))
  285. logger.info('错误文件', e.__traceback__.tb_frame.f_globals['__file__'])
  286. logger.info('错误行号', e.__traceback__.tb_lineno)
  287. data = {
  288. 'errLine': e.__traceback__.tb_lineno,
  289. 'errMsg': repr(e),
  290. }
  291. return JsonResponse(status=200, data=json.dumps(data), safe=False)
  292. @classmethod
  293. def get_combo_msg_type(cls, ai_type, event_type):
  294. """
  295. 获取组合类型,ai_type == 47 支持算法小店,需判断组合类型
  296. """
  297. logger = logging.getLogger('info')
  298. try:
  299. if ai_type != 47:
  300. return event_type
  301. # 如触发一个事件,则匹配已用类型 1替换后变成51代表移动侦测 1:移动侦测,2:人形,4:车型,8:人脸
  302. event_dict = {
  303. 1: 51,
  304. 2: 57,
  305. 4: 58,
  306. 8: 60
  307. }
  308. event_val = event_dict.get(event_type, 0)
  309. # event_val == 0 没有匹配到单个值则认为组合类型
  310. # 如是3,则转为二进制11,代表(1+2)触发了移动侦测+人形侦测
  311. if event_val == 0:
  312. val = cls.dec_to_bin(event_type)
  313. return int(val)
  314. else:
  315. return int(event_val)
  316. except Exception as e:
  317. logger.info('推送错误异常,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
  318. return event_type
  319. @staticmethod
  320. def dec_to_bin(num):
  321. """
  322. 十进制转二进制
  323. """
  324. result = ""
  325. while num != 0:
  326. ret = num % 2
  327. num //= 2
  328. result = str(ret) + result
  329. return result
  330. def push_thread_test(self, push_type, aws_s3_client, bucket, key, uid, appBundleId, token_val, event_type, n_time,
  331. msg_title, msg_text, channel):
  332. logger = logging.getLogger('info')
  333. logger.info('推送图片测试:{} {} {} {} {} {} {} {}'.format(push_type, uid, appBundleId, token_val, event_type, n_time,
  334. msg_title, msg_text))
  335. try:
  336. image_url = aws_s3_client.generate_presigned_url('get_object', Params={'Bucket': bucket, 'Key': key},
  337. ExpiresIn=300)
  338. logger.info('推送图片url:{}'.format(image_url))
  339. if push_type == 0:
  340. GatewayPushService.ios_apns_push(uid, appBundleId, token_val, n_time, event_type, msg_title, msg_text,
  341. uid, channel, image_url)
  342. elif push_type == 1:
  343. GatewayPushService.android_fcm_push(uid, appBundleId, token_val, n_time, event_type, msg_title,
  344. msg_text, uid, channel, image_url)
  345. except Exception as e:
  346. logger.info('推送图片测试异常:{}'.format(e))
  347. def get_msg_title(self, appBundleId, nickname):
  348. package_title_config = {
  349. 'com.ansjer.customizedd_a': 'DVS',
  350. 'com.ansjer.zccloud_a': 'ZosiSmart',
  351. 'com.ansjer.zccloud_ab': '周视',
  352. 'com.ansjer.adcloud_a': 'ADCloud',
  353. 'com.ansjer.adcloud_ab': 'ADCloud',
  354. 'com.ansjer.accloud_a': 'ACCloud',
  355. 'com.ansjer.loocamccloud_a': 'Loocam',
  356. 'com.ansjer.loocamdcloud_a': 'Anlapus',
  357. 'com.ansjer.customizedb_a': 'COCOONHD',
  358. 'com.ansjer.customizeda_a': 'Guardian365',
  359. 'com.ansjer.customizedc_a': 'PatrolSecure',
  360. }
  361. if appBundleId in package_title_config.keys():
  362. return package_title_config[appBundleId] + '(' + nickname + ')'
  363. else:
  364. return nickname
  365. def is_sys_msg(self, event_type):
  366. event_type_list = [702, 703, 704]
  367. if event_type in event_type_list:
  368. return True
  369. return False
  370. def get_msg_text(self, channel, n_time, lang, tz, event_type, electricity='', is_sys=0):
  371. n_date = CommonService.get_now_time_str(n_time=n_time, tz=tz, lang=lang)
  372. etype = int(event_type)
  373. if lang == 'cn':
  374. if etype == 704:
  375. msg_type = '剩余电量:' + electricity
  376. elif etype == 702:
  377. msg_type = '摄像头休眠'
  378. elif etype == 703:
  379. msg_type = '摄像头唤醒'
  380. else:
  381. msg_type = ''
  382. if is_sys:
  383. send_text = '{msg_type} 通道:{channel}'.format(msg_type=msg_type, channel=channel)
  384. else:
  385. send_text = '{msg_type} 通道:{channel} 日期:{date}'.format(msg_type=msg_type, channel=channel, date=n_date)
  386. else:
  387. if etype == 704:
  388. msg_type = 'Battery remaining:' + electricity
  389. elif etype == 702:
  390. msg_type = 'Camera sleep'
  391. elif etype == 703:
  392. msg_type = 'Camera wake'
  393. else:
  394. msg_type = ''
  395. if is_sys:
  396. send_text = '{msg_type} channel:{channel}'. \
  397. format(msg_type=msg_type, channel=channel)
  398. else:
  399. send_text = '{msg_type} channel:{channel} date:{date}'. \
  400. format(msg_type=msg_type, channel=channel, date=n_date)
  401. return send_text
  402. def do_jpush(self, uid, channel, appBundleId, token_val, event_type, n_time,
  403. msg_title, msg_text):
  404. app_key = JPUSH_CONFIG[appBundleId]['Key']
  405. master_secret = JPUSH_CONFIG[appBundleId]['Secret']
  406. _jpush = jpush.JPush(app_key, master_secret)
  407. push = _jpush.create_push()
  408. push.audience = jpush.registration_id(token_val)
  409. push_data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
  410. "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1", "channel": channel}
  411. android = jpush.android(alert=msg_text, priority=1, style=1, alert_type=7,
  412. big_text=msg_text, title=msg_title,
  413. extras=push_data)
  414. push.notification = jpush.notification(android=android)
  415. push.platform = jpush.all_
  416. res = push.send()
  417. print(res)
  418. return res.status_code
  419. def do_fcm(self, uid, channel, appBundleId, token_val, event_type, n_time, msg_title, msg_text):
  420. logger = logging.getLogger('info')
  421. try:
  422. serverKey = FCM_CONFIG[appBundleId]
  423. except Exception as e:
  424. logger.info('------fcm_error:{}'.format(repr(e)))
  425. return 'serverKey abnormal'
  426. push_service = FCMNotification(api_key=serverKey)
  427. data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
  428. "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1", "channel": channel}
  429. result = push_service.notify_single_device(registration_id=token_val, message_title=msg_title,
  430. message_body=msg_text, data_message=data,
  431. extra_kwargs={
  432. 'default_vibrate_timings': True,
  433. 'default_sound': True,
  434. 'default_light_settings': True
  435. })
  436. return result
  437. def do_apns(self, uid, channel, appBundleId, token_val, event_type, n_time, msg_title,
  438. msg_text):
  439. logger = logging.getLogger('info')
  440. logger.info("进来do_apns函数了")
  441. logger.info(token_val)
  442. logger.info(APNS_MODE)
  443. logger.info(os.path.join(BASE_DIR, APNS_CONFIG[appBundleId]['pem_path']))
  444. try:
  445. cli = apns2.APNSClient(mode=APNS_MODE,
  446. client_cert=os.path.join(BASE_DIR, APNS_CONFIG[appBundleId]['pem_path']))
  447. push_data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
  448. "received_at": n_time, "sound": "", "uid": uid, "zpush": "1", "channel": channel}
  449. alert = apns2.PayloadAlert(body=msg_text, title=msg_title)
  450. payload = apns2.Payload(alert=alert, custom=push_data, sound="default")
  451. # return uid, channel, appBundleId, str(token_val), event_type, n_time, msg_title,msg_text
  452. n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
  453. res = cli.push(n=n, device_token=token_val, topic=appBundleId)
  454. print(res.status_code)
  455. logger.info("apns_推送状态:")
  456. logger.info(res.status_code)
  457. if res.status_code == 200:
  458. return res.status_code
  459. else:
  460. print('apns push fail')
  461. print(res.reason)
  462. logger.info('apns push fail')
  463. logger.info(res.reason)
  464. return res.status_code
  465. except (ValueError, ArithmeticError):
  466. return 'The program has a numeric format exception, one of the arithmetic exceptions'
  467. except Exception as e:
  468. print(repr(e))
  469. print('do_apns函数错误行号', e.__traceback__.tb_lineno)
  470. logger.info('do_apns错误:{}'.format(repr(e)))
  471. return repr(e)
  472. def s3_client(region):
  473. if region == 2: # 国内
  474. aws_s3_client = boto3.client(
  475. 's3',
  476. aws_access_key_id=AWS_ACCESS_KEY_ID[0],
  477. aws_secret_access_key=AWS_SECRET_ACCESS_KEY[0],
  478. config=botocore.client.Config(signature_version='s3v4'),
  479. region_name='cn-northwest-1'
  480. )
  481. else: # 国外
  482. aws_s3_client = boto3.client(
  483. 's3',
  484. aws_access_key_id=AWS_ACCESS_KEY_ID[1],
  485. aws_secret_access_key=AWS_SECRET_ACCESS_KEY[1],
  486. config=botocore.client.Config(signature_version='s3v4'),
  487. region_name='us-east-1'
  488. )
  489. return aws_s3_client
  490. def generate_s3_url(aws_s3_client, Params):
  491. response_url = aws_s3_client.generate_presigned_url(
  492. ClientMethod='put_object',
  493. Params=Params,
  494. ExpiresIn=3600
  495. )
  496. return response_url