diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..19daf4a --- /dev/null +++ b/examples/README.md @@ -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 路径 +``` \ No newline at end of file diff --git a/examples/ai.rb b/examples/ai.rb new file mode 100644 index 0000000..68b20fc --- /dev/null +++ b/examples/ai.rb @@ -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 \ No newline at end of file diff --git a/examples/process.rb b/examples/process.rb new file mode 100644 index 0000000..f6e57e9 --- /dev/null +++ b/examples/process.rb @@ -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 diff --git a/lib/upyun/form.rb b/lib/upyun/form.rb index 4dc90e6..7e3e79c 100644 --- a/lib/upyun/form.rb +++ b/lib/upyun/form.rb @@ -30,6 +30,8 @@ class Form x-gmkerl-crop x-gmkerl-exif-switch ext-param + x-gmkerl-thumb + apps ) attr_accessor :bucket, :password diff --git a/lib/upyun/version.rb b/lib/upyun/version.rb index 1185838..00f6c14 100644 --- a/lib/upyun/version.rb +++ b/lib/upyun/version.rb @@ -1,3 +1,3 @@ module Upyun - VERSION = "1.0.9" + VERSION = "1.0.10" end