Cloud Stack Ninja

I use a PHP script to upload some daily videos to a Youtube channel (based on this code sample: https://developers.google.com/youtube/v3/code_samples/php#resumable_uploads)

The problem is after this loop:

// Read the media file and upload it chunk by chunk.
$status = false;
$handle = fopen($videoPath, "rb");
while (!$status && !feof($handle)) {
  $chunk = fread($handle, $chunkSizeBytes);
  $status = $media->nextChunk($chunk);
}

Normally the $status variable has the video id ($status['id']) after the upload is complete but since mid January all the uploads failed with one of this errors:

  • $status variable value stills as "false"
  • Inside the catch, the Google_Service_Exception message is like "A service error occurred: Error calling PUT https://www.googleapis.com/upload/youtube/v3/videos?part=status%2Csnippet&uploadType=resumable&upload_id=xxx: (400) Invalid request. The number of bytes uploaded is required to be equal or greater than 262144, except for the final request (it's recommended to be the exact multiple of 262144). The received request contained nnn bytes, which does not meet this requirement.", where nnn is less than 262144 and seems to be the last request.

When I access the Youtube channel I can see the new videos with a status "Preparing upload" or stuck with a fixed percentage.

My code has not changed for months but now I can't upload any new video.

Anyone can please help me to know what's wrong? Thanks in advance!



Read more here: https://stackoverflow.com/questions/48661317/video-upload-stop-working-youtube-api

Content Attribution

This content was originally published by Astor at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: