Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/459.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 谷歌驱动器api反应本机_Javascript - Fatal编程技术网

Javascript 谷歌驱动器api反应本机

Javascript 谷歌驱动器api反应本机,javascript,Javascript,我是react native的新手,我需要上传一个图像到Google drive,我尝试使用Google drive api包装器,但我有一个错误403,我不知道是什么问题,有人可以解释我如何做到这一点?我显示了我的代码,但我删除了WebClient 我试着用这个例子来指导我 错误[error:{error:{errors:[{域:全局,原因:权限不足,消息:权限不足:请求的身份验证范围不足。}],代码:403,消息:权限不足:请求的身份验证范围不足。}}]您只需要获取映像路径,然后使用rea

我是react native的新手,我需要上传一个图像到Google drive,我尝试使用Google drive api包装器,但我有一个错误403,我不知道是什么问题,有人可以解释我如何做到这一点?我显示了我的代码,但我删除了WebClient

我试着用这个例子来指导我


错误[error:{error:{errors:[{域:全局,原因:权限不足,消息:权限不足:请求的身份验证范围不足。}],代码:403,消息:权限不足:请求的身份验证范围不足。}}]

您只需要获取映像路径,然后使用react本机fs读取该图像。在此之后,将base64映像传递给GDrive包装器

RNFS.readFile(filePath, 'base64').then(res => {
        GDrive.files
          .createFileMultipart(
            res,
            "'image/jpg'",
            {
              parents: ['root'], //or any path
              name: newImageName,
            },
            true,
          )
          .then(response => {
            Alert.alert(
              'Image saved to Google Drive.',
              'Delete image from device?',[
                {text: 'Ok', onPress: () => this.unlinkImage(newFilepath)},
                {
                  text: 'Cancel',
                  onPress: () => console.log('Cancel Pressed'),
                  style: 'cancel',
                }
              ],
              {cancelable: false},
            );
          }).catch = err => {
          console.log('error', err);
        };
      });
看一看
RNFS.readFile(filePath, 'base64').then(res => {
        GDrive.files
          .createFileMultipart(
            res,
            "'image/jpg'",
            {
              parents: ['root'], //or any path
              name: newImageName,
            },
            true,
          )
          .then(response => {
            Alert.alert(
              'Image saved to Google Drive.',
              'Delete image from device?',[
                {text: 'Ok', onPress: () => this.unlinkImage(newFilepath)},
                {
                  text: 'Cancel',
                  onPress: () => console.log('Cancel Pressed'),
                  style: 'cancel',
                }
              ],
              {cancelable: false},
            );
          }).catch = err => {
          console.log('error', err);
        };
      });