Šimon Kováč
Šimon Kováč

Reputation: 1

Cloudinary upload of video file results in "request rejected due to exceeding maximum size" error

I am using Cloudinary to handle file uploads in my Java Spring application. I have a @PutMapping endpoint that receives a video file using multipart/form-data. However, when I attempt to upload the video file, I receive the following error: the request was rejected because its size (27838844) exceeds the configured maximum (10485760)

It seems that Cloudinary is treating the file as an image and applying the lower file size limit instead of the expected limit for videos. How can I specify to Cloudinary that the uploaded file is a video, so that the correct file size limit is applied?

@PutMapping(value = "/update/{id}", consumes = "multipart/form-data")
  public ResponseEntity<Map<String, Object>> UpdateCourse(@RequestParam("file"MultipartFile file, HttpServletRequest request) throws IOException {
Map<String, Object> response = new HashMap<>();
response.put("filename", file.getBytes());

try {
    Map<String, Object> name = cloudinary.uploader().upload(file.getInputStream(), ObjectUtils.asMap("resource_type", "video"));

    response.put("message", "File uploaded successfully");
    response.put("url", name.get("secure_url"));
} catch (Exception e) {
    LOG.info(e.getMessage());
}

return ResponseEntity.ok(response);

}

I have verified that the video file size exceeds the default file size limit for images. I have also checked my Cloudinary account settings and confirmed that the maximum video file size limit is indeed set to a higher value than the error suggests. I have tried specifying "resource_type" as "video" in the options passed to cloudinary.uploader().upload(), but the issue persists. I appreciate any insights or suggestions on how to resolve this issue and correctly specify the file type as a video during the upload process. Thank you!

Upvotes: 0

Views: 108

Answers (0)

Related Questions