Upload Video in Chunks


#1

I am uploading 50 secs of Video in chunks , following are the response for INIT , APPEND and Finalize

INIT
string response = new RequestBuilder( oauth, “POST”, “https://upload.twitter.com/1.1/media/upload.json” )
.AddParameter( “command”, “INIT” )
.AddParameter( “media_type”, mediaType )
.AddParameter( “total_bytes”, file.Length.ToString() )
.Execute();

Returns {“media_id”:645922405773279232,“media_id_string”:“645922405773279232”,“expires_after_secs”:86399}

FOR APPEND

response = new RequestBuilder(oauth, “POST”, “https://upload.twitter.com/1.1/media/upload.json”)
.AddParameter( “command”, “APPEND” )
.AddParameter( “media_id”, initResult.media_id_string )
.AddParameter( “segment_index”, segment.ToString() )
.AddParameter( “media_data”, System.Convert.ToBase64String( bytes ) )
.Execute();

returns response=""

FOR FINALIZE
response = new RequestBuilder( oauth, “POST”, “https://upload.twitter.com/1.1/media/upload.json” )
.AddParameter( “command”, “FINALIZE” )
.AddParameter( “media_id”, initResult.media_id_string )
.Execute();

Returns Response ={“media_id”:645922405773279232,“media_id_string”:“645922405773279232”,“size”:5629360,“expires_after_secs”:86400,“video”:{“video_type”:“video/mp4”}}

Finallly when i GET the status , i get an exception

GET Status
try
{
response = new RequestBuilder( oauth, “GET”, “https://upload.twitter.com/1.1/media/upload.json”)
.AddParameter(“command”, “STATUS”)
.AddParameter(“media_id”, initResult.media_id_string)
.Execute();
}
catch (Exception e)
{

        }

returns error “The remote server returned an error: (400) Bad Request.”


#2

Hi @YUGANT_K. As far as I see at https://dev.twitter.com/rest/public/uploading-media#chunkedupload,

Duration should be between 0.5 seconds and 30 seconds

It’s down the page, at “Video specifications and recommendations”. And you say you’re trying to upload a video that is 50 seconds long.