Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multipart file request for nonexistent file path shows 19 bytes length on server - why? #1318

Open
raffian opened this issue Oct 30, 2024 · 0 comments

Comments

@raffian
Copy link

raffian commented Oct 30, 2024

0.25.1 - RESTClient
1.95.0 - VSCode
WindowsNT/10 x64 10.0.10945

I don't know if this is a problem with the extension or Java/Spring/openapi custom server code handling requests but here goes.

We use this multipart request for uploading PDF files from a client machine; works great.
All parts in the request are required for POST - nothing is optional.

POST http://localhost:8080/upload-test HTTP/1.1
Content-Type: multipart/form-data; boundary="PARTBOUNDARY"

--PARTBOUNDARY
Content-Disposition: form-data; name="testcode"
Content-Type: text/plain

UPLOAD_CODE_1
--PARTBOUNDARY
Content-Disposition: form-data; name="context"
Content-Type: application/json

{"id": "123"}
--PARTBOUNDARY
Content-Disposition: form-data; name="file"; filename="notexist.pdf"
Content-Type: application/pdf

< C:/files/temp/notexist.pdf
--PARTBOUNDARY--

Problem

If we change the file path to a nonexistent file, the request is still sent and does not generate warning or error.
Upon receiving the request on the server, we check the file part content length to be 19 bytes.
Very strange - where does 19 bytes come from if the file part in the request was for nonexistent file?
How does the extension prepare and send multipart request when file path is invalid?

    @Override
    public ResponseEntity<UploadApiResponse> uploadStuff( 
        @Valid String testcode,
        MultipartFile file,
        @Valid RequestCtx context, ) {

         if(file != null){
             log.info("file size: " + file.getSize());    //file size = 19 bytes for nonexistent file uploaded in request?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant