• byte数组与MultipartFile相互转化


    文章来源

    https://www.cnblogs.com/nongzihong/p/13370606.html

     

    MultipartFile转化为byte数组

    byte[] imgBytes = multipartFile.getBytes();

      

    byte数组转化为MultipartFile

     

    转换中我们会使用MockMultipartFile这个类,所有要引用相应包。
                    <dependency>
                       <groupId>org.springframework</groupId>
                       <artifactId>spring-test</artifactId>
                       <version>RELEASE</version>
                    </dependency>

    byte[] testFile = new byte[1024];
    InputStream inputStream = new ByteArrayInputStream(testFile);
    MultipartFile file = new MockMultipartFile(ContentType.APPLICATION_OCTET_STREAM.toString(), inputStream);

    zzzzzzzzzzzz
  • 相关阅读:
    快速排序
    Web总结
    浏览器兼容性问题汇总
    AngularJS理论基础
    预处器的对比——Sass、LESS.
    js事件知识整理
    Java script基础
    重拾nodeJs
    全国城市三级联动
    js 获取地址栏参数
  • 原文地址:https://www.cnblogs.com/ymlyxp/p/15325393.html
Copyright © 2020-2023  润新知