7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/backup2qiniu/cli.rb', line 7
def gen_token
puts 'input your keys (you can find them on https://portal.qiniu.com/setting/key)'
token = get_param("Access Key")
secret = get_param("Secret Key")
Qiniu::RS.establish_connection! :access_key => token, :secret_key => secret
buckets = Qiniu::RS.buckets
unless buckets
puts 'Can not verify your key, wrong key?'
exit 1
end
bucket = get_bucket_name(buckets)
days = get_param("Token Valid Days (365)")
if days == ''
days = 365
else
days = days.to_i
end
print_params access_key: token, secret_key: secret, bucket: bucket, valid_days: days
print_token Qiniu::RS.generate_upload_token(:expires_in => 3600*24*days, :scope => bucket), bucket
end
|