Below is my Rest Controller Code:

@RestController
@RequestMapping(FileServerController.ROOT_MAPPING)
public class FileServerController {

    public static final String ROOT_MAPPING = "/api/fileserver";

    private final SequenceGeneratorService sequenceGeneratorService;
    private final StorageService storageService;
    private final S3Factory s3Factory;

    public FileServerController(SequenceGeneratorService sequenceGeneratorService, StorageService storageService, S3Factory s3Factory) {
        this.sequenceGeneratorService = sequenceGeneratorService;
        this.storageService = storageService;
        this.s3Factory = s3Factory;
    }

    @PostMapping(value = "/add/file", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
    private ResponseEntity<ResponseMessage<String>> uploadFile(
            @RequestPart("files") List<MultipartFile> files) {
        this.storageService.storeFileOnS3Bucket(files.get(0));
        ResponseMessage<String> responseMessage = new ResponseMessage<>();
        responseMessage.setMessage("File added: " + files.get(0).getOriginalFilename());

        return new ResponseEntity<>(responseMessage, HttpStatus.OK);
    }
}

Problem is when i am invoking it via POSTMAN as below:

curl --location --request POST 'http://localhost:8096/api/fileserver/add/file' \
--form 'files=@"/G:/My Drive/Money_receipt.jpg"'

I can see valid file is coming inside the method but all the injected beans are NULL Screenshot 2022-05-12 201230

If i invoke other API inside the same REST Controller, this error is not coming. I think something wrong with @RequestPart

My Environment: Java 17 (zulu17.28.13-ca-jdk17.0.0-win_x64) Spring Boot: 2.6.7

Comment From: bclozel

Thanks for getting in touch, but it feels like this is a question that would be better suited to StackOverflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.

Comment From: rajibhalder

Thank You @bclozel , As you suggested, i posted this question to StackOverFlow.