mylemans / google-api-dotnet-client

Automatically exported from code.google.com/p/google-api-dotnet-client
Apache License 2.0
0 stars 0 forks source link

Upload doesn't work #446

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Make a new C# (4.5) console project in Visual Studio 2013
2. Use this code: http://pastebin.com/Ls4HTqV8 (really simple uploader)
3. Add your client_secrets.json from the Google API Console
4. Run the Programm
5. Allow access in the newly opened browser(-tab)

What is the expected output? What do you see instead?
The video should get uploaded.
Instead it first shows:
"Bytes sent: 0, Status: Starting, Exception:"
Then after a good 2 minutes:
"Bytes sent: 0, Status: Failed, Exception: 
System.Threading.Tasks.TaskCanceledException: A task was canceled."

What version of the product are you using?
What is your operating system? Windows 8.1 64Bit
What is your IDE? Visual Studio 2013 R1
What is the .NET framework version? 4.5

Please provide any additional information below.

Original issue reported on code.google.com by theonlys...@gmail.com on 4 Feb 2014 at 8:03

GoogleCodeExporter commented 9 years ago
Step 2.1) install latest nuget with "Install-Package Google.Apis.YouTube.v3 
-Pre"

Original comment by theonlys...@gmail.com on 4 Feb 2014 at 8:04

GoogleCodeExporter commented 9 years ago
Stacktrace:
System.AggregateException was unhandled.
  HResult=-2146233088
  Message=One or more errors occurred.
  Source=mscorlib
  StackTrace:
       at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
       at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
       at System.Threading.Tasks.Task`1.get_Result()
       at Google.Apis.Upload.ResumableUpload`1.Upload() in c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\output\default\Src\GoogleApis\Apis\[Media]\Upload\ResumableUpload.cs:line 351
       at UploadTest.Program.<>c__DisplayClass2.<Main>b__1() in e:\Development\Repositories\YouTube Reloader\UploadTest\Program.cs:line 52
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Threading.Tasks.TaskCanceledException
       HResult=-2146233029
       Message=A task was canceled.
       InnerException: 

Original comment by theonlys...@gmail.com on 5 Feb 2014 at 11:06

GoogleCodeExporter commented 9 years ago
More data is available here - 
http://stackoverflow.com/questions/21559550/youtube-api-upload-files-without-any
-error-c

Original comment by pele...@google.com on 5 Feb 2014 at 9:07

GoogleCodeExporter commented 9 years ago
Tried to run the same sample but eventually I got 401 - Unauthorized.

[ I tried to run it with NET 4.5 and got runtime error, solved that one ]
The reason the upload is canceled is based on error in Microsoft.Bcl.Async 
package.
There is more information in 
http://stackoverflow.com/questions/21057052/google-api-oauth2-c-sharp-asp-net-ap
p-crashes-could-not-load-file-or-assembl.

I just ran your code in my machine, and t didn't work as I expected. So, I 
solved that one by copy the content of 
"packages\Microsoft.Bcl.Async.1.0.16\lib\net40" into my bin folder.
I already opened an issue for the owners of the Bcl.Async package, and they 
might solved this issue soon, but meantime you have a solution.

Original comment by pele...@google.com on 6 Feb 2014 at 3:12

GoogleCodeExporter commented 9 years ago
I tried 2 things, but they still result in the same error.
1) Change the Project to .NET 4.0 (and reinstall the nugets) that way 
"Microsoft.Threading.Tasks.Extensions.Desktop.dll" will be in the bin folder
2) Use .NET 4.5 and simply copy the 
"Microsoft.Threading.Tasks.Extensions.Desktop.dll" over to the bin folder

PS: The video actually shows up on YouTube, but it is "Processing" and never 
actually uploaded.

Original comment by theonlys...@gmail.com on 6 Feb 2014 at 11:38

GoogleCodeExporter commented 9 years ago
Actually I think the "Microsoft.Threading.Tasks.Extensions.Desktop.dll" has 
nothing to do with the upload failing. It is only once needed to open a new 
browser for the authentication, as soon as the app is authorized you actually 
don't need it anymore, the app will run just fine without that dll in the bin 
folder.

Original comment by theonlys...@gmail.com on 6 Feb 2014 at 11:45

GoogleCodeExporter commented 9 years ago
I agree. I just wanted to write down the process I had 
(Microsoft.Threading.Tasks.Extensions.Desktop.dll)
Can you attach the fiddler output for all the trafic?

Original comment by pele...@google.com on 6 Feb 2014 at 1:08

GoogleCodeExporter commented 9 years ago
Here you go.(I removed the first HTTP tunnel and oauth authentication for 
security reasons, if you need it feel free to write me an email)
If you look at the PUT-Request: 10485760 Bytes have been sent (in the bodies), 
the video is 11176345 Bytes big...
Edit: I actually can't upload it because "Project attachment quota exceeded." I 
will send you the attachment via email.

Original comment by theonlys...@gmail.com on 6 Feb 2014 at 3:44

GoogleCodeExporter commented 9 years ago
see my answer in 
http://stackoverflow.com/questions/21559550/youtube-api-upload-files-without-any
-error-c/21610550#21610550

I think I got it.
Let me know

Original comment by pele...@google.com on 6 Feb 2014 at 6:02

GoogleCodeExporter commented 9 years ago
It works now. Guess my internet is just to slow so the task times out.

Original comment by theonlys...@gmail.com on 6 Feb 2014 at 6:20

GoogleCodeExporter commented 9 years ago

Original comment by pele...@google.com on 6 Feb 2014 at 6:38