From 3af57e97ce8335d66eae53fed8806d88f66ccae2 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 17 Aug 2019 16:19:36 +0800 Subject: [PATCH] video feature: modify --- app/libs/aliyun_vod/service/base.rb | 10 +++++++++- app/libs/aliyun_vod/service/video_upload.rb | 9 --------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/libs/aliyun_vod/service/base.rb b/app/libs/aliyun_vod/service/base.rb index 85f74fc6f..e100eadcc 100644 --- a/app/libs/aliyun_vod/service/base.rb +++ b/app/libs/aliyun_vod/service/base.rb @@ -10,7 +10,15 @@ module AliyunVod::Service::Base Rails.logger.info("[AliyunVod] response => status: #{response.status}, result: #{result}") - raise AliyunVod::Error, result['Code'] if response.status != 200 + if response.status != 200 + message = + case result['Code'] + when 'InvalidFileName.Extension' then '不支持的文件格式' + when 'IllegalCharacters' then '文件名称包含非法字符' + else raise AliyunVod::Error, result['Message'] + end + raise AliyunVod::Error, message if message.present? + end result rescue => ex diff --git a/app/libs/aliyun_vod/service/video_upload.rb b/app/libs/aliyun_vod/service/video_upload.rb index a5ade72f9..97ecd970b 100644 --- a/app/libs/aliyun_vod/service/video_upload.rb +++ b/app/libs/aliyun_vod/service/video_upload.rb @@ -16,15 +16,6 @@ module AliyunVod::Service::VideoUpload result = request(:post, params) - if result['Code'].present? - message = - case result['Code'] - when 'InvalidFileName.Extension' then '不支持的文件格式' - when 'IllegalCharacters' then '文件名称包含非法字符' - end - raise AliyunVod::Error, message if message.present? - end - raise AliyunVod::Error, '获取上传凭证失败' if result['UploadAddress'].blank? result