资源简介
七牛js文件上传,含后台代码,获取 token
代码片段和文件信息
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class QiNiuAction {
@RequestMapping(value = “/qiniu/getToken“ method = {RequestMethod.GETRequestMethod.POST})
public @ResponseBody ModelMap getQiuNiuToken(@RequestParam String dir@RequestParam String fileName HttpServletRequest request
HttpServletResponse response) {
response.setHeader(“Access-Control-Allow-Origin““*“);
//这个路径必须与qiniu.html中task.file.name相等
String token = QiNiuUtil.getInstance().getToken(“/uploadFiles/diandian/topicCover/“+fileName);
//String token = QiNiuUtil.getInstance().getToken(dir+fileName);
if (StringUtil.isBlank(token)) {
return ActionResultUtil.genErrorMsgMap(“请重试.“);
} else {
Mapject> data = new HashMapject>();
data.put(“token“ token);
data.put(“dir“ dir);
return ActionResultUtil.genSuccessDataMap(data);
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1372 2017-01-20 17:19 QiniuAction.java
文件 5494 2017-01-20 17:21 qiniu.html
文件 56932 2017-01-20 10:08 qiniu4js.js
----------- --------- ---------- ----- ----
63798 3
评论
共有 条评论