Problems Uploading Videos - media type unrecognized



Hi! I’m developing an app using Java 8 and spring socials twitter.
Iknow that you dont support 3rd parts code but i can see that its a twitter api problem.

I need to upload videos to Twitter and then Tweet it with its description.

I’m using the same method to upload images, gifs and videos:
For images and gifs it runs OK, but it fails with videos returning "media type unrecognized"
I use “media_data” parameter to send the Base64Encoded file.

Here is my code:

MultiValueMap<String, Object> uploadParams = new LinkedMultiValueMap<>();
uploadParams.set("media_data", imageData.getImageBase64()); //its encoded
MediaUploadResponse response = executePostCommandWithReturn(() -> twitter.restOperations().postForObject("", uploadParams, MediaUploadResponse.class));

I tried to use the chunk method to upload videos but in the INIT command it fails with the same error “media type unrecognized”. On this case, i’m sending “video/mp4” on the parameter “media_type”. (following the example on documentation)

I dont know what else to check.


Thanks for the additional context and information from your other post.

I’m looking into what might be up with the format of the media. I realise that you’ve said that the same file works via so there’s clearly some discrepancy here.


Yes, I’ve try to uploads some videos in and it works ok.

In addition: One of my videos size is of no more than 1mb.


Andy, do you have any news about my problem?

My problem is not only with these video. I cant upload any video.


Are you able to provide a more complete sample that demonstrates the issue you are having, so we can attempt to reproduce?


Yes, I’m but tell me which info do you need.


Ideally, an end-to-end sample in Spring Social that we can compile, with a variety of test videos.


Hello. I would really like your help/guide to uploading video media to user account using spring social. Implemented the chunks as per Twitter API guide but nothing seems to work. Thank you


I’m not very familiar with Spring Social so I’d need to look at some sample code to potentially diagnose the issue here.


Thanks. Your guide to this issue will be much appreciated.


Are you able to share any code?


Yes I can. All this code can do is copy the video file to a new destination and save the file name and path to the database other than that, I tried sending the video as a tweet but it fails Error: org.springframework.web.client.HttpClientErrorException: 400 Bad Request or ERROR: 400 :: media type unrecognized.


You probably initialize file upload with media_type as “application/octet-stream”. You should find exact content type, for example “video/mp4”, of the file and then set this value for media_type.

BTW, it is strange that error is raised on FINALIZE, not on INIT method call.

closed #14