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))
}