• 大小: 8.47MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-07
  • 语言: Java
  • 标签:

资源简介

SpringMVC上传图片文件到 腾讯云,前端使用Ajax,亲测可用。

资源截图

代码片段和文件信息

package com.neusoft.controller;

import com.neusoft.util.COSClientUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author XiaoLuo
 * @ClassName: UserController
 * @Description: ${todo}
 * @date 2017/9/1 17:57
 */
@Controller
public class UploadController {

@RequestMapping(“/“)
public ModelAndView index() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName(“index“);
return modelAndView;
}


@RequestMapping(“/upload“)
@ResponseBody
public object upload(@RequestParam(“file“) MultipartFile file)throws Exception{
COSClientUtil cosClientUtil = new COSClientUtil();
String name = cosClientUtil.uploadFile2Cos(file);
String imgUrl = cosClientUtil.getImgUrl(name);
String[] split = imgUrl.split(“\\?“);
return split[0];
}







}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        290  2018-04-02 17:50  test-cos\.idea\artifacts\test_cos_war.xml

     文件       3316  2018-04-02 18:33  test-cos\.idea\artifacts\test_cos_war_exploded.xml

     文件        628  2018-04-02 17:50  test-cos\.idea\compiler.xml

     文件        517  2018-04-02 21:10  test-cos\.idea\libraries\Maven__aopalliance_aopalliance_1_0.xml

     文件        546  2018-04-02 21:10  test-cos\.idea\libraries\Maven__commons_codec_commons_codec_1_10.xml

     文件        608  2018-04-02 21:10  test-cos\.idea\libraries\Maven__commons_fileupload_commons_fileupload_1_3_1.xml

     文件        506  2018-04-02 21:10  test-cos\.idea\libraries\Maven__commons_io_commons_io_2_2.xml

     文件        561  2018-04-02 21:10  test-cos\.idea\libraries\Maven__commons_logging_commons_logging_1_2.xml

     文件        647  2018-04-02 21:10  test-cos\.idea\libraries\Maven__com_fasterxml_jackson_core_jackson_annotations_2_5_0.xml

     文件        598  2018-04-02 21:10  test-cos\.idea\libraries\Maven__com_fasterxml_jackson_core_jackson_core_2_5_1.xml

     文件        626  2018-04-02 21:10  test-cos\.idea\libraries\Maven__com_fasterxml_jackson_core_jackson_databind_2_5_1.xml

     文件        499  2018-04-02 21:10  test-cos\.idea\libraries\Maven__com_qcloud_cos_api_5_2_4.xml

     文件        581  2018-04-02 21:10  test-cos\.idea\libraries\Maven__javax_servlet_javax_servlet_api_3_1_0.xml

     文件        497  2018-04-02 21:10  test-cos\.idea\libraries\Maven__javax_servlet_jsp_api_2_0.xml

     文件        525  2018-04-02 21:10  test-cos\.idea\libraries\Maven__javax_servlet_servlet_api_2_4.xml

     文件        509  2018-04-02 21:10  test-cos\.idea\libraries\Maven__joda_time_joda_time_2_9_6.xml

     文件        472  2018-04-02 21:10  test-cos\.idea\libraries\Maven__log4j_log4j_1_2_16.xml

     文件        580  2018-04-02 21:10  test-cos\.idea\libraries\Maven__org_apache_httpcomponents_httpclient_4_5_3.xml

     文件        566  2018-04-02 21:10  test-cos\.idea\libraries\Maven__org_apache_httpcomponents_httpcore_4_4_6.xml

     文件        516  2018-04-02 21:10  test-cos\.idea\libraries\Maven__org_slf4j_slf4j_api_1_7_21.xml

     文件        544  2018-04-02 21:10  test-cos\.idea\libraries\Maven__org_slf4j_slf4j_log4j12_1_7_21.xml

     文件        612  2018-04-02 21:10  test-cos\.idea\libraries\Maven__org_springframework_spring_aop_4_2_4_RELEASE.xml

     文件        626  2018-04-02 21:10  test-cos\.idea\libraries\Maven__org_springframework_spring_beans_4_2_4_RELEASE.xml

     文件        640  2018-04-02 21:10  test-cos\.idea\libraries\Maven__org_springframework_spring_context_4_2_4_RELEASE.xml

     文件        619  2018-04-02 21:10  test-cos\.idea\libraries\Maven__org_springframework_spring_core_4_2_4_RELEASE.xml

     文件        661  2018-04-02 21:10  test-cos\.idea\libraries\Maven__org_springframework_spring_expression_4_2_4_RELEASE.xml

     文件        633  2018-04-02 21:10  test-cos\.idea\libraries\Maven__org_springframework_spring_webmvc_4_2_4_RELEASE.xml

     文件        612  2018-04-02 21:10  test-cos\.idea\libraries\Maven__org_springframework_spring_web_4_2_4_RELEASE.xml

     文件        566  2018-04-02 17:50  test-cos\.idea\misc.xml

     文件        256  2018-04-02 17:49  test-cos\.idea\modules.xml

............此处省略86个文件信息

评论

共有 条评论