我try 使用javascript媒体上传程序.js将youtube视频上传到我自己的账户,由于某种原因,我在OneError函数中遇到了以下错误:

"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."

我今天只测试了几次,但出现了一个奇怪的错误.

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个查询,我的配额限制是10000个查询/天.

预期:成功将我的视频上传到我的youtube帐户.

推荐答案

Youtube每天不会给你10000个查询,而是给你10000个单元;一个查询可以是多个单元,具体取决于您正在执行的操作:

一个简单的读取操作,只检索返回的每个文件的ID

写操作的成本约为50个单元.

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

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

更多信息:

React-native相关问答推荐

Redux将旧状态迁移到新状态

类似Snapchat的Reaction Native筛选器

在 React Native 中,水平滚动不适用于我的整个应用程序

一旦我关闭应用程序,Json struct 就会发生变化

使用 Auth Token 标头react 本机图像,如何处理 401?

React Native - 何时调用componentWillUnmount?

应用程序主体尚未注册

React native flexbox - 如何做 percentages || columns || responsive || grid etc

什么时候适合在 React 中使用构造函数?

library not found for -lRCTGeolocation

如何在 react-native 中在子级和父级之间传递数据?

使用 resizeMode = contain时的图像对齐

React Native - NSNumber 无法转换为 NSString

error TS2300: Duplicate identifier 'RequestInfo'

元素中缺少main.jsbundle、Foundation和Security,导致报错

路由状态没有通过 redux 保持在 react-native

自定义标签栏react Navigation 5

React native expection java.lang.UnsatisfiedLinkError: dlopen failed: "/data/data/{package}/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit

等待模块失效的超时

为react-native TextInput 设置边框