0
我試圖文件上傳與tweetinvi.File上傳工作,爲圖像,但相同的代碼沒有顯示視頻(大型視頻超過20 MB)tweetinvi分塊上傳大量上載
我在這裏問,但現在answear
TweetInvi Large Video Upload Failing With Null Reference
,所以我另找solution.There是tweetinvi分塊上傳 我這個編碼,但它不工作,不給錯誤,但它不工作
if (file.ContentType.Contains("video"))//video
{
var video1 = System.IO.File.ReadAllBytes(path);
var chunk = Upload.CreateChunkedUploader(); //Create an instance of the ChunkedUploader class (I believe this is the only way to get this object)
using (FileStream fs = System.IO.File.OpenRead(path))
{
chunk.Init("video/mp4", (int)fs.Length); //Important! When initialized correctly, your "chunk" object will now have a type long "MediaId"
byte[] buffer = new byte[video1.Length]; //Your chunk MUST be 5MB or less or else the Append function will fail silently.
int bytesRead = 0;
while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) > 0)
{
byte[] copy = new byte[bytesRead];
Buffer.BlockCopy(buffer, 0, copy, 0, bytesRead);
TimeSpan s = new TimeSpan();
chunk.Append(copy, chunk.NextSegmentIndex.ToString()); //The library says the NextSegment Parameter is optional, however I wasn't able to get it to work if I left it out.
}
}
var video = chunk.Complete(); //This tells the API that we are done uploading.
listMedia.Add(video);
}
我會調查您的問題。我在https://github.com/linvi/tweetinvi/issues/528上的github網站上添加了這個問題 – Linvi