PutPolicy struct for uploading. And you have to specify right scope
and deadline to let uploading work.
See http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html
Summary
Functions
A better way to build PutPolicy, which can calculate deadline for you from expires_in(seconds) and can accpet the options. See build/2, build/3.
build/3
Change put_policy to json string and encode it with url safe
Change put_policy to json string expect the nil values, whose keys are camelCase.
Types
@type t() :: %ExOss.CDN.Qiniu.PutPolicy{ callback_body: String.t() | nil, callback_body_type: String.t() | nil, callback_fetch_key: integer() | nil, callback_host: String.t() | nil, callback_url: String.t() | nil, checksum: String.t() | nil, deadline: integer(), detect_mime: integer() | nil, end_user: String.t() | nil, file_type: integer() | nil, force_save_key: boolean() | nil, fsize_limit: integer() | nil, fsize_min: integer() | nil, insert_only: integer() | nil, is_prefixal_scope: integer() | nil, mime_limit: String.t() | nil, persistent_notify_url: String.t() | nil, persistent_ops: String.t() | nil, persistent_pipeline: String.t() | nil, return_body: String.t() | nil, return_url: String.t() | nil, save_key: String.t() | nil, scope: String.t() }
Functions
A better way to build PutPolicy, which can calculate deadline for you from expires_in(seconds) and can accpet the options. See build/2, build/3.
Examples
iex> ExOss.CDN.Qiniu.PutPolicy.build("scope")
%ExOss.CDN.Qiniu.PutPolicy{scope: "scope", deadline: NOW_TIME + 3600}
build/2
Examples
iex> ExOss.CDN.Qiniu.PutPolicy.build("scope", 4000)
%ExOss.CDN.Qiniu.PutPolicy{scope: "scope", deadline: NOW_TIME + 4000}
iex> ExOss.CDN.Qiniu.PutPolicy.build("scope", insert_only: 1)
%ExOss.CDN.Qiniu.PutPolicy{scope: "scope", deadline: NOW_TIME + 3600, insert_only: 1}
build/3
Examples
iex> ExOss.CDN.Qiniu.PutPolicy.build("scope", 4000, insert_only: 1)
%ExOss.CDN.Qiniu.PutPolicy{scope: "scope", deadline: NOW_TIME + 4000, insert_only: 1}
# scope and deadline in options won't be used for override
iex> ExOss.CDN.Qiniu.PutPolicy.build("scope", 4000, scope: "other_scope")
%ExOss.CDN.Qiniu.PutPolicy{scope: "scope", deadline: NOW_TIME + 4000}
Change put_policy to json string and encode it with url safe
Examples
iex> policy = %ExOss.CDN.Qiniu.PutPolicy{scope: "scope"}
iex> ExOss.CDN.Qiniu.PutPolicy.encoded_json(policy)
"eyJzY29wZSI6InNjb3BlIn0="
Change put_policy to json string expect the nil values, whose keys are camelCase.
Examples
iex> policy = %ExOss.CDN.Qiniu.PutPolicy{scope: "scope", deadline: 1427990400, return_body: "body"}
iex> ExOss.CDN.Qiniu.PutPolicy.to_json(policy)
~s({"deadline":1427990400,"returnBody":"body","scope":"scope"})