1

I am trying to make a video upload using angular and spring boot. I am using ng-file-upload in angular and in the controller I am using the following method to upload the file

   Upload.upload({
       url: 'api/uploadFile',
       data: {file: file, 'username': $scope.username}
   })

On the server I have declared my resource like this

@RestController
@RequestMapping("/api")
public class FileUploadResource {

    @ResponseStatus(HttpStatus.OK)
    @PostMapping("/uploadFile")
    public void uploadFile(@RequestParam("file") MultipartFile file,  @RequestParam("username") String name)

When I try uploading the file I keep receiving a 500 error and I can't figure out how to solve it. If you could help me or if you could suggest another method that would be great

Thanks.

2 Answers 2

1

Is the uploadFile controller method being called? I'm guessing an exception is being thrown from the uploadFile method, in which case you should have a stack trace showing in your server log that will direct you to where the problem lies.

Sign up to request clarification or add additional context in comments.

1 Comment

No, the method isn't called. I don't have a stack trace, I receive "error.internalServerError".
0

Set headers in your upload to:

headers: { 'Content-Type': undefined }

It's better to send your data like this:

var formData = new FormData();
formData.append("file", file);
formData.append("username", username);

And put formData as upload's data to send.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.