Problems Uploading Videos - media type unrecognized

media-upload
java
spring
springsocial

#1

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: https://upload.twitter.com/1.1/media/upload.json
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("https://upload.twitter.com/1.1/media/upload.json", 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.


#2

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 Twitter.com so there’s clearly some discrepancy here.


#3

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

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


#4

Andy, do you have any news about my problem?

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


#5

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


#6

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


#7

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


#8

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


#9

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


#10

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


#11

Are you able to share any code?


#12

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.


#13

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.


#14