Method: COS::Bucket#upload_all
- Defined in:
- lib/cos/bucket.rb
#upload_all(path_or_dir, file_src_path, options = {}) {|Float| ... } ⇒ Array<COS::COSFile>
Note:
已存在的文件不会再次上传, 本地目录中的隐藏文件(已“.”开头的)不会上传“.cpt”文件不会上传, 不会上传子目录
批量上传目录下的全部文件(不包含子目录)
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/cos/bucket.rb', line 278 def upload_all(path_or_dir, file_src_path, = {}, &block) local_path = Util.get_local_path(file_src_path, true) uploaded = [] Dir.foreach(local_path) do |file| if !file.start_with?('.') and !file.end_with?('.cpt') and !File.directory?(file) logger.info("Begin to upload file >> #{file}") begin # 逐个上传 uploaded << upload(path_or_dir, file, "#{local_path}/#{file}", , &block) rescue => error # 跳过错误 if [:skip_error] logger.info("#{file} error skipped") next else # 终止上传抛出异常 raise error end end logger.info("#{file} upload finished") end end uploaded end |