I have a problem with uploading videos using LinqToTwitter
. I have a sample code, which works fine when it's called in a Console application
, but hangs when it's used in a WebForms
project.
private static ulong UploadMedia()
{
const string path = "c:\\Temp\\video.mp4";
var authorizer = new SingleUserAuthorizer
{
CredentialStore = new SingleUserInMemoryCredentialStore
{
ConsumerKey = "my_consumer_key",
ConsumerSecret = "my_consumer_secret",
AccessToken = "my_access_token",
AccessTokenSecret = "my_access_token_secret"
}
};
var tc = new TwitterContext(authorizer);
var media = UploadMediaAsync(tc, File.ReadAllBytes(path)).Result;
return media.MediaID;
}
private static async Task<Media> UploadMediaAsync(TwitterContext tc, byte[] media)
{
return await tc.UploadMediaAsync(media, "video/mp4");
}
Anyone has an idea what goes wrong?