簡體   English   中英

春天上傳后文件大小正在變化

[英]Size of the file is changing after upload in spring

我正在嘗試在本地Spring Java Web應用程序中上載apk文件,但是由於校驗和失敗,因此在文件上載后文件的大小正在更改。

基本上,磁盤上文件的大小與我在應用程序中收到的文件的大小不同。

我完全一無所知,我不確定如何繼續進行調試。

PS:在上傳過程中創建的臨時文件(tmp文件夾)的大小比我最初上傳的文件大。

代碼:

@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代碼:

上傳文件請求頁面

    <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引起了問題。

我終於弄清楚了問題所在,

我已經向該應用程序添加了日志記錄過濾器,這將更改該日志記錄過濾器中的請求。 刪除了更改請求的部分。 現在工作正常。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM