请求无法完成,因为您已超出配额 [英] The request cannot be completed because you have exceeded your quota

查看:50
本文介绍了请求无法完成,因为您已超出配额的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 javascript MediaUploader.js 将 youtube 视频上传到我自己的帐户,由于某种原因,我在 onError 函数中收到此错误:

I tried to use the javascript MediaUploader.js to upload youtube video to my own account, for some reason, I got this error in onError function:

"errors": [
   {
    "domain": "youtube.quota",
    "reason": "quotaExceeded",
    "message": "The request cannot be completed because you have exceeded your \u003ca href=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e."
   }
  ],
  "code": 403,
  "message": "The request cannot be completed because you have exceeded your \u003ca href=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e."

我今天只测试了几次,但遇到了这个奇怪的错误.

I only tested a few times today, but got this strange error.

var signinCallback = function (tokens, file){
console.log("signinCallback tokens: ",tokens);
if(tokens.accessToken) { //tokens.access_token
  console.log("signinCallback tokens.accessToken: ",tokens.accessToken);
  var metadata = {
    id: "101",
    snippet: {
      "title": "Test video upload",
      "description":"Description of uploaded video",
      "categoryId": "22",//22
      "tags": ["test tag1", "test tag2"],
    },
    status: {
        "privacyStatus": "private",
        "embeddable": true,
        "license": "youtube"
    }
    };
  console.log("signinCallback Object.keys(metadata).join(','): ",Object.keys(metadata).join(','));
  var options = {
    url: 'https://www.googleapis.com/upload/youtube/v3/videos?part=snippet%2Cstatus&key=<my api key>',

    file: file,
    token: tokens.accessToken,
    metadata: metadata,
    contentType: 'application/octet-stream',//"video/*",
    params: {
      part: Object.keys(metadata).join(',')
    },
    onError: function(data) {
      var message = data;
      // Assuming the error is raised by the YouTube API, data will be
      // a JSON string with error.message set. That may not be the
      // only time onError will be raised, though.
      try {
        console.log("signinCallback onError data: ",data);
        if(data!="Not Found"){
            var errorResponse = JSON.parse(data);
            message = errorResponse.error.message;
            console.log("signinCallback onError message: ",message);
            console.log("signinCallback onError errorResponse: ",errorResponse);
        }else{

        }
      } finally {
        console.log("signinCallback error.... ");
      }
    }.bind(this),
    onProgress: function(data) {
      var currentTime = Date.now();
      var bytesUploaded = data.loaded;
      var totalBytes = data.total;
      // The times are in millis, so we need to divide by 1000 to get seconds.
      var bytesPerSecond = bytesUploaded / ((currentTime - this.uploadStartTime) / 1000);
      var estimatedSecondsRemaining = (totalBytes - bytesUploaded) / bytesPerSecond;
      var percentageComplete = (bytesUploaded * 100) / totalBytes;
      console.log("signinCallback onProgress bytesUploaded, totalBytes: ",bytesUploaded, totalBytes);
      console.log("signinCallback onProgress percentageComplete: ",percentageComplete);
    }.bind(this),
    onComplete: function(data) {
      console.log("signinCallback onComplete data: ",data);
      var uploadResponse = JSON.parse(data);
      this.videoId = uploadResponse.id;
      //this.pollForVideoStatus();
    }.bind(this)
  }
  MediaUpload.videoUploader(options);
}

};

我查看了我的配额的开发者控制台,我的配额限制太大了,我没有办法超过我的配额,例如,我今天总共有 89 个查询,我的配额限制是 10,000 个查询/天.

I checked the developer console of my quota, my quota limit is so big, there is no way I exceeded my quota, ex, I have total of 89 queries today, and my quota limit is 10,000 queries/day.

预期:成功将我的视频上传到我的 YouTube 帐户.实际结果:quotaExceeded

Expected: upload my video to my youtube account successfully. Actual results: quotaExceeded

推荐答案

Youtube 不是每天给你 10,000 个查询,他们每天给你 10,000 个单位;一个查询可以是多个单位,具体取决于您在做什么:

Youtube does not give you 10,000 Queries a day, they give you 10,000 units a day; a query can be multiple units, depending on what you're doing:

一个简单的读操作,只检索每个返回的ID资源的成本约为 1 个单位.

A simple read operation that only retrieves the ID of each returned resource has a cost of approximately 1 unit.

一次写入操作的成本约为 50 个单位.

A write operation has a cost of approximately 50 units.

一次视频上传的成本约为 1600 个单元.

A video upload has a cost of approximately 1600 units.

如果您的 89 个查询包含视频上传或写入操作,则可以解释您的问题

If your 89 queries contain video uploads or write operations, then that would explain your issue

更多信息:https://developers.google.com/youtube/v3/getting-started#配额

这篇关于请求无法完成,因为您已超出配额的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆