Class: Qiniu::Auth::PutPolicy

Inherits:
Object
  • Object
show all
Defined in:
lib/qiniu/auth.rb

Overview

class << self

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bucketObject (readonly)

Returns the value of attribute bucket.



79
80
81
# File 'lib/qiniu/auth.rb', line 79

def bucket
  @bucket
end

#keyObject (readonly)

Returns the value of attribute key.



79
80
81
# File 'lib/qiniu/auth.rb', line 79

def key
  @key
end

Instance Method Details

#allow_mime_list!(list) ⇒ Object

expires_in



122
123
124
# File 'lib/qiniu/auth.rb', line 122

def allow_mime_list! (list)
  @mime_limit = list
end

#deny_mime_list!(list) ⇒ Object

allow_mime_list!



126
127
128
# File 'lib/qiniu/auth.rb', line 126

def deny_mime_list! (list)
  @mime_limit = "!#{list}"
end

#detect_mime!Object

insert_only!



134
135
136
# File 'lib/qiniu/auth.rb', line 134

def detect_mime!
  @detect_mime = 1
end

#expires_inObject

expires_in=



118
119
120
# File 'lib/qiniu/auth.rb', line 118

def expires_in
  return @expires_in
end

#expires_in!(seconds) ⇒ Object

scope!



103
104
105
106
107
108
109
110
111
112
# File 'lib/qiniu/auth.rb', line 103

def expires_in!(seconds)
  if !seconds.nil? then
    return @expires_in
  end

  @epires_in = seconds
  @deadline  = Auth.calculate_deadline(seconds)

  return @expires_in
end

#expires_in=(seconds) ⇒ Object

expires_in!



114
115
116
# File 'lib/qiniu/auth.rb', line 114

def expires_in=(seconds)
  return expires_in!(seconds)
end

#insert_only!Object

deny_mime_list!



130
131
132
# File 'lib/qiniu/auth.rb', line 130

def insert_only!
  @insert_only = 1
end

#scope!(bucket, key = nil) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/qiniu/auth.rb', line 81

def scope!(bucket, key = nil)
  @bucket = bucket
  @key    = key

  if key.nil? then
    # 新增语义,文件已存在则失败
    @scope = bucket
  else
    # 覆盖语义,文件已存在则直接覆盖
    @scope = "#{bucket}:#{key}"
  end

  if Config.settings[:multi_region]
    begin
      @uphosts = Config.host_manager.up_hosts(bucket)
      @global = Config.host_manager.global(bucket)
    rescue
      # Do nothing
    end
  end
end

#to_jsonObject

detect_mime!



138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/qiniu/auth.rb', line 138

def to_json
  args = {}

  PARAMS.each_pair do |key, fld|
    val = self.__send__(key)
    if !val.nil? then
      args[fld] = val
    end
  end

  return args.to_json
end