question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uploading video results in stream error

See original GitHub issue

I’m trying to upload videos to Facebook using the methods in place as follows:

        dynamic parameters = new ExpandoObject();
        parameters.source = new fb.FacebookMediaObject { ContentType = mimeType, FileName = request.Filename }
            .SetValue(ServiceCommon.Common.GetBytesFromStream(videoData).ToArray());
        parameters.title = request.Title;
        parameters.description = request.Description;

but when I do large videos (>~20mb), I get the following error consistently: Facebook upload failed: mimetype [video/mp4]System.Net.WebException: The request was aborted: The request was canceled. —> System.IO.IOException: Cannot close stream until all bytes are written. at System.Net.ConnectStream.CloseInternal(Boolean internalCall, Boolean aborting) — End of inner exception stack trace — at System.Net.ConnectStream.CloseInternal(Boolean internalCall, Boolean aborting) at System.Net.ConnectStream.System.Net.ICloseEx.CloseEx(CloseExState closeState) at System.Net.ConnectStream.Dispose(Boolean disposing) at System.IO.Stream.Close() at System.IO.Stream.Dispose() at Facebook.FacebookClient.Api(HttpMethod httpMethod, String path, Object parameters, Type resultType) at Facebook.FacebookClient.Post(String path, Object parameters) at CallSite.Target(Closure , CallSite , FacebookClient , String , Object ) at FacebookTransferService.Upload(FacebookUploadRequest request, Stream videoData)

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bc3techcommented, Jul 13, 2012

Changing from fb.Post(endpointUri, parameters); to Task t = fb.PostTaskAsync(endpointUri, parameters); t.Wait();

appears to have done the trick.

Thanks.

-----Original Message----- From: Prabir Shrestha [mailto:reply@reply.github.com] Sent: Thursday, July 12, 2012 11:40 PM To: bc3tech Subject: Re: [facebook-csharp-sdk] Uploading video results in stream error (#181)

For attachments (photo/video) upload it is highly recommended not to use byte array. Use FacebookMediaStream instead and use the async version PostAsync or PostTaskAsync. You can find how to use FacebookMediaStream at http://csharpsdk.org/docs/making-asynchronous-requests

Let us know if it works then.


Reply to this email directly or view it on GitHub: https://github.com/facebook-csharp-sdk/facebook-csharp-sdk/issues/181#issuecomment-6954555

0reactions
prabirshresthacommented, Jul 13, 2012

Try setting HttpWebRequest.Timeout = -1; (or higher value) and HttpWebRequest. ReadWriteTimeout to a higher value.

This is an advanced option and will most likely be hidden from intellisense depending on your VS settings. You can learn about how to set it at http://stackoverflow.com/a/10931752/157260

You can use async in server side using IHttpAsyncHandler http://msdn.microsoft.com/en-us/library/system.web.ihttpasynchandler.aspx There are other options if you are using mvc.

I don’t consider this a bug but rather an excepted result.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to upload video to Microsoft stream
I have very few videos (less than 10) uploaded on Microsoft Stream, but when I try to upload a new one, I get...
Read more >
Microsoft Stream (Classic) upload errors
List of Stream (Classic) upload errors with explanations. ... using Stream (on SharePoint) by uploading videos to SharePoint, Teams, Yammer, ...
Read more >
"Error Uploading: Video could not successfully be created. ...
I've been trying to re-upload edited VODs due to some personal information showing up on stream. I edited the original stream into two...
Read more >
office 365 - Video failed to upload to Microsoft Stream
I have tried multiple times yesterday and today. Also asked another team member to try and they receive the same error message. office-365 ......
Read more >
Decoding error - when uploading video via curl - Stream
Hi, we are using CURL to upload a file located on a particular URL - to stream . However we keep getting this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found