Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support process and examples #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# ruby sdk examples

这些 examples 旨在帮助您快速了解使用又拍云 ruby-sdk。

这些 examples 都可以直接运行,但是在运行之前,需要根据您的需求填写相应的参数。

### 参数举例说明:

身份信息

```
`Bucket` 您的空间名

`Password` 您的表单 API 密钥
```

参数信息

```
`Notify_Url` 通知回调 URL

`Local_File` 本地文件路径

`Save_Key` 云存储中 save-key 路径

`Save_As` 云存储中 save_as 路径
```
48 changes: 48 additions & 0 deletions examples/ai.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# encoding: utf-8
#------------------------------------------------------------------
#提供了人工智能相关的使用实例
#------------------------------------------------------------------

require 'upyun'

# 需要填写自己的服务名,密码,通知URL
Bucket = ''
Password = ''
Notify_Url = ''

# 需要填写上传文件路径,云端存储路径
Local_File = ''
Save_Key = ''
Save_As = ''

# 初始化一个实例
$upyun = Upyun::Form.new(Password, Bucket)

# 内容识别-图片上传预处理
def imageAsyncAudit
# 参数详见人工智能,云存储文档
apps = [HashWithIndifferentAccess.new({
'name' => 'imgaudit'
})]
opts = HashWithIndifferentAccess.new({
'save-key' => Save_Key,
'notify-url' => Notify_Url,
'apps' => apps
})
puts $upyun.upload(Local_File, opts)
end

# 内容识别-点播上传预处理
def videoAsyncAudit
# 参数详见人工智能,云存储文档
apps = [HashWithIndifferentAccess.new({
'name' => 'videoaudit',
'save_as' => Save_As
})]
opts = HashWithIndifferentAccess.new({
'save-key' => Save_Key,
'notify-url' => Notify_Url,
'apps' => apps
})
puts $upyun.upload(Local_File, opts)
end
77 changes: 77 additions & 0 deletions examples/process.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# encoding: utf-8
#------------------------------------------------------------------
#提供了云处理相关的使用实例
#------------------------------------------------------------------

require 'upyun'

# 需要填写自己的服务名,密码,
Bucket = ''
Password = ''

# 需要填写通知URL, 上传文件路径,云端存储路径
Notify_Url = ''
Local_File = ''
Save_Key = ''
Save_As = ''

# 初始化一个实例
$upyun = Upyun::Form.new(Password, Bucket)

# 图片处理-同步上传预处理
def imageSyncProcess
# 参数详见同步图片处理,云存储文档
opts = HashWithIndifferentAccess.new({
'save-key' => Save_Key,
'x-gmkerl-thumb' => '/format/png'
})
puts $upyun.upload(Local_File, opts)
end

# 图片处理-异步上传预处理
def imageAsyncProcess
# 参数详见异步图片处理,云存储文档
apps = [HashWithIndifferentAccess.new({
'name' => 'thumb',
'x-gmkerl-thumb' => '/format/png',
'save_as' => Save_As
})]
opts = HashWithIndifferentAccess.new({
'save-key' => Save_Key,
'notify-url' => Notify_Url,
'apps' => apps
})
puts $upyun.upload(Local_File, opts)
end

# 异步音视频处理
def videoAsyncProcess
# 参数详见异步音视频处理,云存储文档
apps = [HashWithIndifferentAccess.new({
'name' => 'naga',
'type' => 'video',
'avopts' => '/s/128x96',
'save_as' => Save_As
})]
opts = HashWithIndifferentAccess.new({
'save-key' => Save_Key,
'notify-url' => Notify_Url,
'apps' => apps
})
puts $upyun.upload(Local_File, opts)
end

# 文档转换
def uconvetAsyncProcess
# 参数详见文档转换,云存储文档
apps = [HashWithIndifferentAccess.new({
name: 'uconvert',
save_as: Save_As
})]
opts = HashWithIndifferentAccess.new({
'save-key' => Save_Key,
'notify-url' => Notify_Url,
'apps' => apps
})
puts $upyun.upload(Local_File, opts)
end
2 changes: 2 additions & 0 deletions lib/upyun/form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class Form
x-gmkerl-crop
x-gmkerl-exif-switch
ext-param
x-gmkerl-thumb
apps
)

attr_accessor :bucket, :password
Expand Down
2 changes: 1 addition & 1 deletion lib/upyun/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Upyun
VERSION = "1.0.9"
VERSION = "1.0.10"
end