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.



81
82
83
# File 'lib/qiniu/auth.rb', line 81

def bucket
  @bucket
end

#keyObject (readonly)

Returns the value of attribute key.



81
82
83
# File 'lib/qiniu/auth.rb', line 81

def key
  @key
end

Instance Method Details

#allow_mime_list!(list) ⇒ Object

expires_in



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

def allow_mime_list! (list)
  @mime_limit = list
end

#deny_mime_list!(list) ⇒ Object

allow_mime_list!



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

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

#detect_mime!Object

insert_only!



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

def detect_mime!
  @detect_mime = 1
end

#expires_inObject

expires_in=



111
112
113
# File 'lib/qiniu/auth.rb', line 111

def expires_in
  return @expires_in
end

#expires_in!(seconds) ⇒ Object

scope!



96
97
98
99
100
101
102
103
104
105
# File 'lib/qiniu/auth.rb', line 96

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!



107
108
109
# File 'lib/qiniu/auth.rb', line 107

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

#insert_only!Object

deny_mime_list!



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

def insert_only!
  @insert_only = 1
end

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



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/qiniu/auth.rb', line 83

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

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

#to_jsonObject

detect_mime!



131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/qiniu/auth.rb', line 131

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