0

I'm trying to upload a Reference video to YouTube, I've already created the Asset, but whenever I try inserting the Reference I get Request Entity Too Large error, although the file I'm uploading is 3.4MB while the API documentation states that the maximum file size is 20GB.

Any ideas what am I doing wrong?

Here's my code sample:

fs.readFile(FILE_PATH, function(err, data) {
    if (!err) {
        ytpapi.references.insert({
            auth: oauth2Client,
            onBehalfOfContentOwner: contentOwner,
            resource: {
                assetId: ASSET_ID,
                contentType: 'video',
                media: {
                    mimeType: 'video/mp4',
                    body: data.Body
                }
            }
        }, function (err, data) {

            if (err) {
                console.log(err);
            }

            console.log('Success');
        });
    }
});
AboulEinein
  • 1,101
  • 3
  • 13
  • 27

1 Answers1

0

I found the problem. I mistakenly added the media object under the resource object.

Here's the correct code sample in case anyone needs it:

fs.readFile(FILE_PATH, function(err, data) {
    if (!err) {
        ytpapi.references.insert({
            auth: oauth2Client,
            onBehalfOfContentOwner: contentOwner,
            resource: {
                assetId: ASSET_ID,
                contentType: 'video'
            },
            media: {
                mimeType: 'video/mp4',
                body: data.Body
            }
        }, function (err, data) {

            if (err) {
                console.log(err);
            }

            console.log('Success');
        });
    }
});
AboulEinein
  • 1,101
  • 3
  • 13
  • 27