|
@@ -57,6 +57,8 @@ class UserDeviceShareView(View):
|
|
|
return self.get_wallpaper_list(request_dict, response)
|
|
|
elif operation == 'getUploadWallpaper':
|
|
|
return self.get_upload_wallpaper(request_dict, response)
|
|
|
+ elif operation == 'notifyUploadWallpaper':
|
|
|
+ return self.notify_upload_wallpaper(request_dict, response)
|
|
|
elif operation == 'delWallpaper':
|
|
|
return self.del_wallpaper(request_dict, response)
|
|
|
elif operation == 'selectWallpaper':
|
|
@@ -296,9 +298,6 @@ class UserDeviceShareView(View):
|
|
|
if not uid:
|
|
|
return response.json(444)
|
|
|
|
|
|
- device_info_qs = Device_Info.objects.filter(UID=uid).values('id', 'Type')
|
|
|
- device_type = device_info_qs[0]['Type'] if device_info_qs.exists() else ''
|
|
|
-
|
|
|
# 初始化存储桶客户端
|
|
|
if CONFIG_CN == CONFIG_INFO or CONFIG_TEST == CONFIG_INFO:
|
|
|
s3 = boto3.client(
|
|
@@ -331,7 +330,35 @@ class UserDeviceShareView(View):
|
|
|
ExpiresIn=600
|
|
|
)
|
|
|
|
|
|
- # 考虑再写一个回调接口创建壁纸
|
|
|
+ # 返回预签名的URL和字段
|
|
|
+ return response.json(0, {
|
|
|
+ 'uploadUrl': presigned_url,
|
|
|
+ 'fileName': file_name,
|
|
|
+ })
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ LOGGER.error('获取上传链接异常:errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+ return response.json(5)
|
|
|
+
|
|
|
+ @classmethod
|
|
|
+ def notify_upload_wallpaper(cls, request_dict, response):
|
|
|
+ """
|
|
|
+ 确认壁纸上传成功,创建DeviceWallpaper
|
|
|
+ @param request_dict:
|
|
|
+ @param response:
|
|
|
+ @return:
|
|
|
+ """
|
|
|
+ try:
|
|
|
+ uid = request_dict.get('uid', None)
|
|
|
+ file_name = request_dict.get('fileName', None)
|
|
|
+ channel = int(request_dict.get('channel', 1))
|
|
|
+
|
|
|
+ if not all([uid, file_name]):
|
|
|
+ return response.json(444)
|
|
|
+
|
|
|
+ device_info_qs = Device_Info.objects.filter(UID=uid).values('id', 'Type')
|
|
|
+ device_type = device_info_qs[0]['Type'] if device_info_qs.exists() else ''
|
|
|
+
|
|
|
DeviceWallpaper.objects.create(
|
|
|
device_type=device_type,
|
|
|
storage_type=1,
|
|
@@ -344,15 +371,10 @@ class UserDeviceShareView(View):
|
|
|
parent_id=0,
|
|
|
created_time=int(time.time())
|
|
|
)
|
|
|
-
|
|
|
- # 返回预签名的URL和字段
|
|
|
- return response.json(0, {
|
|
|
- 'uploadUrl': presigned_url,
|
|
|
- 'fileName': file_name,
|
|
|
- })
|
|
|
+ return response.json(0)
|
|
|
|
|
|
except Exception as e:
|
|
|
- LOGGER.error('获取上传链接异常:errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+ LOGGER.error('壁纸创建失败:errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
return response.json(5)
|
|
|
|
|
|
@classmethod
|
|
@@ -429,4 +451,4 @@ class UserDeviceShareView(View):
|
|
|
return response.json(0)
|
|
|
except Exception as e:
|
|
|
LOGGER.error('用户选取壁纸异常:errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
- return response.json(5)
|
|
|
+ return response.json(5)
|