skip to Main Content

I am uploading video to Twitter in chunks using Twitter Media API and then trying to call FINALIZE.
Keep on getting:
“Large file can not be finalized synchronously.”

result = new RequestBuilder(oauth, "POST", "https://upload.twitter.com/1.1/media/upload.json")
            .AddParameter("command", "FINALIZE")
            .AddParameter("media_id", media_id)
            .Execute().Result;

//code from Execute
            try
            {
                response = await request.GetResponseAsync().ConfigureAwait(false);
                using (var stream = response.GetResponseStream())
                {
                    using (var reader = new StreamReader(stream))
                    {
                        content = reader.ReadToEnd();
                    }
                }
            }
 catch (WebException ex)
            {
                using (var stream = ex.Response.GetResponseStream())
                {
                    using (var reader = new StreamReader(stream))
                    {
                        content = reader.ReadToEnd();
                    }
                }
                throw;
            }
            finally
            {
                if (response != null)
                {
                    ((IDisposable)response).Dispose();
                }
            }

2

Answers


  1. I never received this exception. Have you tried using tweetinvi and see if it works for the same file?

    Please note that Twitter only supports 15MB video.

    Wiki for video upload : https://github.com/linvi/tweetinvi/wiki/Upload#upload-videos. The video are automatically chunked to satisfy Twitter requirements (5MB per chunk for video).

    var video = File.ReadAllBytes("path");
    var media = Upload.UploadVideo(video);
    var tweet = Tweet.PublishTweet("hello", new PublishTweetOptionalParameters
    {
        Medias = { media }
    });
    

    If you really want to do this manually you can still use the ChunkUploader:

    https://github.com/linvi/tweetinvi/wiki/Upload#chunked-uploads

    Login or Signup to reply.
  2. Twitter does support larger videos up to 512Mb, requirements can be found on this page: https://developer.twitter.com/en/docs/media/upload-media/uploading-media/media-best-practices

    In order to upload larger files you have to set the media_category parameter to “tweet_video” in the INIT call. The FINALIZE call will then give you processing_info that you need to follow up with the STATUS command call.

    .post("media/upload", {
          command: "INIT",
          total_bytes: mediaSize,
          media_type: mediaType,
          media_category: 'tweet_video'
      })
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search