Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The send request in done in 2 parts... You send the header, including the size of the video as you have... YouTube responds with a url, and you send the video to that url.. Looks like you are trying to send all in one request. Something a bit like this.</p> <pre><code>Try Try _request = CType(WebRequest.Create(_requestUrl), HttpWebRequest) With _request .ContentType = "application/atom+xml; charset=UTF-8" .ContentLength = _postBytes.Length .Method = "POST" .Headers.Add("Authorization", String.Format("GoogleLogin auth={0}", MasterAccessToken.ClientLoginToken)) .Headers.Add("GData-Version", "2") .Headers.Add("X-GData-Key", String.Format("key={0}", YouTube.Constants.Security.DEVELOPERKEY)) .Headers.Add("Slug", filename) End With _writeStream = _request.GetRequestStream With _writeStream .Write(_postBytes, 0, _postBytes.Length) End With Using _response = CType(_request.GetResponse, HttpWebResponse) With _response If .StatusCode = HttpStatusCode.OK OrElse .StatusCode = HttpStatusCode.Created Then _ans = _response.Headers("Location") Else Throw New WebException("Cannot get ClientLogin upload location", Nothing, WebExceptionStatus.ProtocolError, _response) End If End With End Using Catch ex As Exception Finally If _writeStream IsNot Nothing Then _writeStream.Close() End If End Try _videoUploadLocation = _ans 'Got the upload location..... now get the file Dim _file As FileInfo = New FileInfo(filename) Dim _fileLength As Integer Using _fileStream As System.IO.FileStream = _file.OpenRead _fileLength = CType(_fileStream.Length, Integer) If _fileLength = 0 Then Throw New FileLoadException("File appears to be of zero length in UploadVideoFromFileClientLogin:", filename) End If 'create the webrequest _request = CType(WebRequest.Create(_videoUploadLocation), HttpWebRequest) 'No authentication headers needed.. With _request .Timeout = 6000000 'Timeout for this request changed to 10 minutes .ReadWriteTimeout = 6000000 .KeepAlive = True .ContentType = "application/octet-stream" .ContentLength = _fileLength .Method = "POST" End With 'and get the stream _writeStream = _request.GetRequestStream 'And send it over the net m_StreamUtils.CancelRequest = False m_StreamUtils.SendStreamToStream(_fileStream, _writeStream, AddressOf UploadPogressChanged) m_CancelRequest = m_StreamUtils.CancelRequest End Using If Not (m_CancelRequest) Then Using _response = CType(_request.GetResponse, HttpWebResponse) With _response If .StatusCode = HttpStatusCode.Created Then _ans = _response.ResponseUri.AbsoluteUri Else Throw New WebException("Cannot get ClientLogin upload location", Nothing, WebExceptionStatus.ProtocolError, _response) End If End With End Using Else _ans = String.Empty End If If _writeStream IsNot Nothing Then _writeStream.Close() End If </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload