Sha256: d764e928908b9ac7aa367b6cf5070c60cbcba27afd729303ab7b54c7d2a0720e
Contents?: true
Size: 1.16 KB
Versions: 5
Compression:
Stored size: 1.16 KB
Contents
require 'lhj/helper/oss_helper' module Lhj class Command class Local < Command class Upload < Local self.summary = '上传中英文对照csv文件' def self.options [ %w[--upload-file 上传中英文对照csv文件名] ] end def initialize(argv) @pwd_path = argv.shift_argument || Dir.pwd @upload_csv_file = argv.option('upload-file', '*.csv') super end def csv_file_name file_name = @upload_csv_file file_name = "#{@upload_csv_file}.csv" unless /.csv$/ =~ @upload_csv_file file_name end def csv_oss_key(file_name) "csv/#{Time.now.to_i}/#{file_name}" end def run csv_files = File.join(@pwd_path, '**', csv_file_name) Dir.glob(csv_files).each do |f| file_name = File.basename(f) oss_key = csv_oss_key file_name Lhj::OSS::Helper.instance.upload(oss_key, f) url = Lhj::OSS::Helper.instance.object_url(oss_key) puts "云端上传成功.下载Url:#{url}\n" end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems