春天上传后文件大小正在变化 [英] Size of the file is changing after upload in spring

查看:45
本文介绍了春天上传后文件大小正在变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在本地Spring Java Web应用程序中上载apk文件,但是由于校验和失败,文件大小在上载后发生了变化.

I am trying to upload an apk file in my local spring java web application, but the size of the file is getting changed after its uploaded as a result of which checksum is failing.

基本上,磁盘上的文件大小与我在应用程序中收到的文件大小不同.

basically the size of the file on disk is different than the size of the file I receive in my application.

我是一无所知,我不确定该如何继续调试.

I am completely clueless, I am not sure how to go on debugging this.

PS:在上传过程中创建的临时文件(tmp文件夹)的大小比我最初上传的文件大.

PS: the temp file(tmp folder) which gets created during uploading has increased size than the one I originally upload.

代码:

@RequestMapping(value = "/app", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA)
public Application upload(@RequestParam(value = "apkFile", required=false) MultipartFile apkFile, 
                          @RequestParam(value = "iconFile", required=false) MultipartFile iconFile, 
                          @RequestParam Map<String, String> params, HttpServletRequest request, 
                          Authentication authentication) {
    //process
}

我使用的依赖项

<dependency>
    <groupId>commons-fileupload</groupId>
    <artifactId>commons-fileupload</artifactId>
    <version>1.3.2</version>
</dependency>

<dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.5</version>
</dependency>

我使用的HTML代码:

Html code I use :

上载文件请求页面

    <form method="POST"
        action="http://localhost:8080/devicemanagement_administration/admin/api/v1/application/app"
        enctype="multipart/form-data">
        type(binary,icon or screenshot): <input type="text" name="contentType"><br />
         tenantId(ibm or google): <input type="text" name="tenantId"><br />
        <br /> platform(android or ios): <input type="text" name="platform"><br />
        File to upload: <input type="file" id="apkFile" name="apkFile"><br /> content
        <br /> <input type="submit" value="Upload"> Press here to
        upload the file!
    </form>

</body>
</html>

PS:我尝试上传文本和json文件,上传后大小没有变化..只有大多数apk引起了问题.

PS:i tried uploading text and json files, the size doesnt change after uploading.. only most apks are causing issues.

推荐答案

我终于弄清楚了问题所在,

I finally figured out what was the issue,

我已经向该应用程序添加了日志过滤器,这将更改该日志过滤器中的请求.删除了更改请求的部分.现在工作正常.

I had put a logging filter to this application which would alter the request in that logging filter. Removed the part where the request is altered. working fine now.

这篇关于春天上传后文件大小正在变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆