使用CSE SDK如何进行文件上传

该博客提供了文件上传下载的开发文档参考链接,包括ServiceComb的文件上传和下载文档。还给出了代码示例参考,即ServiceComb提供的DEMO链接,其中包含大量开发示例,指明了下载和上传示例对应的文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

文件上传下载的开发文档参考:

  *  https://docs.servicecomb.io/java-chassis/zh_CN/general-development/file-upload.html

  * https://docs.servicecomb.io/java-chassis/zh_CN/general-development/file-download.html

 

代码示例可以参考ServiceComb提供的DEMO:https://github.com/apache/servicecomb-java-chassis

里面有大量的开发示例,下载的示例在DownloadSchema.java, 上传的在CodeFirstSpringmvc.java

 

快速参考:

上传

1

2

3

4

5

6

  @RequestMapping(path = "/upload", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)

  @Override

  public String fileUpload(@RequestPart(name = "file1") MultipartFile file1,

      @RequestPart(name = "someFile") MultipartFile file2, @RequestAttribute("name") String name) {

    return super.fileUpload(file1, file2, name);

  }

下载

1

2

3

4

5

6

7

8

9

10

11

12

13

14

  // generate HttpHeaders.CONTENT_DISPOSITION to be "attachment;filename=tempFilePart.txt" automatically

  @GetMapping(path = "/tempFilePart")

  public Part tempFilePart(String content) throws IOException {

    File file = createTempFile(content);

 

    return new FilePart(null, file)

        .setDeleteAfterFinished(true)

        .setSubmittedFileName("tempFilePart.txt");

  }

 

  @GetMapping(path = "/file")

  public File file(String content) throws IOException {

    return createTempFile("file.txt", content);

  }

  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值