七牛 表单上传图片,不能覆盖?
key = aaa.jpg
第2次上传同样的key,不能覆盖。
<form method="post" action="http://up.qiniu.com/" enctype="multipart/form-data">
<input name="token" type="text" value="@ViewBag.upToken" />
<input type="text" name="x:album" value="albumId"><br>
<input name="key" value="@ViewBag.pictureName"><br>
<input type="file" name="file"><br>
<button type="submit">上传<tton>
<label id="info" style="display:none;color:red"></label>
</form>
要使用覆盖上传的场景,需要将上传策略中的scope设为:的形式,并且在客户端的key需要与scope中严格一致。参考:
http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html#put-policy-scope
这种情况下,不同的key必须单独构造putPolicy并生成token。
这是为了防止误覆盖文件而做的限制。