require 'upyun'web
upyun = Upyun::Rest.new('bucket', 'operator', 'password')app
# 本地路徑: ./folder/1/2/3.jpg, 那麼,上傳到 遠程後,應該是: <host>/1/2/3.jpg, happyteam.b0.upaiyun.com/1/2/3.jpgui
# 執行這個腳本的要求是:spa
# 1. cd 到 目標文件夾的同級目錄,例如: /opt/app/yuehouse_web/publicrem
# 2. 目標文件夾(例如: files ). 直接:it
root ='/Users/zhangyu/Pictures'class
folder = '/files'require
files_and_folders = `find #{root + folder}`file
files_and_folders.split("\n").select{ |entity|select
entity.include?(".")
}.each { |file|
remote_file_path = file.sub(root, '')
puts upyun.put(remote_file_path, File.new(file))
}