Skip to content

Commit

Permalink
Merge pull request #3 from loganhz/main
Browse files Browse the repository at this point in the history
Fix decode error and enable task mode
  • Loading branch information
rsonghuster authored Sep 23, 2022
2 parents cd6b0fe + 60ca66b commit 103c482
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
10 changes: 5 additions & 5 deletions publish.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Type: Application
Name: start-unzip-oss
Version: 0.0.9
Version: 0.0.10
Provider:
- 阿里云
Description: 使用函数计算自动解压上传到OSS指定前缀目录的zip文件
Expand Down Expand Up @@ -67,8 +67,8 @@ Parameters:
roleArn:
title: RAM角色ARN
type: string
default: ''
pattern: '^acs:ram::[0-9]*:role/.*$'
default: ""
pattern: "^acs:ram::[0-9]*:role/.*$"
description: 应用所属的函数计算服务配置的 role, 请提前创建好对应的 role, 授信函数计算服务, 并配置好 AliyunOSSFullAccess 和 AliyunFCDefaultRolePolicy policy。
required: true
x-role:
Expand Down Expand Up @@ -106,8 +106,8 @@ Parameters:
triggerRoleArn:
title: 触发器RAM角色ARN
type: string
default: ''
pattern: '^acs:ram::[0-9]*:role/.*$'
default: ""
pattern: "^acs:ram::[0-9]*:role/.*$"
description: OSS使用此角色来发送事件通知来调用函数
required: true
x-role:
Expand Down
5 changes: 4 additions & 1 deletion src/code/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ def get_zipfile_name(origin_name): # 解决中文乱码问题
except:
name = name_bytes.decode(encoding="gb18030")
else:
name = name_bytes.decode(encoding="gb18030")
try:
name = name_bytes.decode(encoding="gb18030")
except:
name = name_bytes.decode(encoding="utf-8")
return name


Expand Down
14 changes: 11 additions & 3 deletions src/s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# 更多函数计算案例,可参考:https://github.com/devsapp/awesome/
# 有问题快来钉钉群问一下吧:33947367
edition: 1.0.0
name: UnZip OSS
name: UnZip OSS
# access 是当前应用所需要的密钥信息配置:
# 密钥配置可以参考:https://www.serverless-devs.com/serverless-devs/command/config
# 密钥使用顺序可以参考:https://www.serverless-devs.com/serverless-devs/tool#密钥使用顺序与规范
Expand All @@ -35,7 +35,7 @@ services:
role: "{{ roleArn }}"
internetAccess: true
function:
name: "{{ functionName }}"
name: "{{ functionName }}"
handler: index.handler
timeout: 7200
runtime: python3
Expand All @@ -44,6 +44,14 @@ services:
environmentVariables:
PROCESSED_DIR: "{{ processedDir }}"
RETAIN_FILE_NAME: "{{ retainFileName }}"
# 如果是很大的 ZIP 文件, 想使用异步调用,可以开启如下配置, 将每次函数调用看做一个任务执行
asyncConfiguration:
# destination:
# onSuccess: acs:fc:::services/${vars.service.name}/functions/dest-succ
# onFailure: acs:fc:::services/${vars.service.name}/functions/dest-fail
maxAsyncEventAgeInSeconds: 7200
maxAsyncRetryAttempts: 3
statefulInvocation: true
triggers:
- name: unzip-oss-trigger
type: oss
Expand All @@ -58,4 +66,4 @@ services:
Key:
Prefix: "{{ prefix }}"
Suffix: .zip
bucketName: "{{ bucketName }}"
bucketName: "{{ bucketName }}"

0 comments on commit 103c482

Please sign in to comment.