1

我使用密钥 (P12) 访问 Google 云端硬盘

我可以浏览文件夹,获取有关文件的数据,获取 Google 驱动器中的文件列表。但我无法将文件上传到 Google 驱动器。

在 TEAM 上一切正常(是所有者)

为什么不给我保存文件的机会?

示例代码我成功获得了文件夹列表:

def is_file_in_folder(service, folder_id, file_id):
  try:
    service.children().get(folderId=folder_id, childId=file_id).execute()
  except errors.HttpError, error:
    if error.resp.status == 404:
      return False
    else:
      print 'An error occurred: %s' % error
      raise error
  return True

我试图保存文件的示例代码:

def insert_file(service, title, description, parent_id, mime_type, filename):
  media_body = MediaFileUpload(filename, mimetype=mime_type, resumable=True)
  body = {
    'title': title,
    'description': description,
    'mimeType': mime_type
  }
  if parent_id:
    body['parents'] = [{'id': parent_id}]

  try:
    file = service.files().insert(body=body, media_body=media_body).execute()

    return file
  except errors.HttpError, error:
    print 'An error occured: %s' % error
    return None

显示错误 - ERROR

我假设文件正在尝试加载,但有些东西阻止了他,以及(resumable = True),他一次又一次地尝试,直到时间。

我需要什么才能上传文件?

尝试使用代码在 Google 驱动器中创建文件夹,但显示错误(经过身份验证的用户没有对文件的所需访问权限)

那么如何获得这些权利呢?

4

1 回答 1

1

发现了问题。它出现在界面“Google Drive”上显示正确的文件夹是只读的,没有人能够将文件上传到它。正因为如此,并给出一个错误并且只允许读取。

顺便说一句,有人可以知道如何获得文件的直接链接。这种格式?: http: //google.com/my_file.mp3

于 2013-01-17T11:56:08.220 回答